file upload as url

mparrett 11 Mar, 2009
hello,
i would like the entry in the database for the file upload to show as a url, so that when retrieving the data later, there is a hyperlink to that file
currently, the name of the file is shown in the database and the location of the file itself is in the uploads folder of chronocontact
can you advise on what changes to make to the html for this to happen
currently:
<div class="form_item">
<div class="form_element cf_fileupload">
<label class="cf_label">CV</label>
<input class="cf_fileinput" size="20" id="file_0" name="cv" type="file" />

</div>
thanks in advance
Matt
mparrett 11 Mar, 2009
Thanks
I'm almost there on my test site - only trouble is I am getting a strange URL, duplicating folders and going into my home directory (the file label is called cv):

This is the code I put in: <?PHP
JRequest::setVar('cv', 'http://www.etax.co.uk/components/com_chronocontact/uploads/testuploading/'.$attachments['cv']);
?>

And this is a sample from the database file (ignore opening quotes to avoid long hyperlink):
"http://www.etax.co.uk/components/com_chronocontact/uploads/testuploading//home/etax/public_html/components/com_chronocontact/uploads/testuploading/20090311163106_cook.doc



Cheers
Matt
Max_admin 12 Mar, 2009
Hi,

try to replace:
$attachments['cv']


by:

$_FILES['cv']['name']


Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
mparrett 12 Mar, 2009
almost there:
I am getting"http://www.etax.co.uk/components/com_chronocontact/uploads/TESTUP2NOREG/enquiry.doc

missing the autogenerated prefix such as 20090312151126_enquiry.doc

so the hlink still incorrect

thanks
Matt
(will be buying license for my real site shortly, once I have mastered things!!)
GreyHead 12 Mar, 2009
Hi Matt,

Looks as though $attachments has a path and you need a url. We worked through this in a thread on renaming images a month or two ago - all the code is in the forums somehwere.

Bob
Max_admin 13 Mar, 2009
Hi Matt,

try this:



JRequest::setVar('cv', 'http://www.etax.co.uk/'.str_replace(JPATH_SITE, '', $attachments['cv']));


Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
mparrett 13 Mar, 2009
fantastic, thanks Max
Have just bought my license
Great support
Matt
This topic is locked and no more replies can be posted.