Buy Now
Sign in

Dynamically setting image upload path

ugly , March 05 2010, 15:22
ugly 31
March 05 2010, 15:22 #48152
I use my form to upload multiple images onto the server into a set location. At present I set this under the 'File Upload Setting' tab here you can insert a path for your uploaded files "/home/******/public_html/images/articleimages/ . This works fine, however I would like the flexibility to set the file upload path dynamically in the form. Is this possible?
GreyHead 65
March 05 2010, 16:04 #48158
Hi ugly,

The file upload code is executed very early on in the form submission work flow so you can't easily change the path without hacking the code.

What you can do is to move the uploaded file to another folder though. Using the Joomla JFile methods you can do this in the OnSubmit code in a few lines.

If you'd like to buy me a coffee or two, thank you very much
nml375 1
March 05 2010, 16:06 #48159
Yes, this is possible with a little creative coding. I posted a workaround some time ago to allow uploads to go into separate directories for each user. The trick is to use the uploaded file name code to add a path into the filename. This path has to be relative to the upload directory, and you should be very careful when coding this, as this could possibly allow users to upload potentionally bad files to replace key files in Joomla... A good start is to not allow the user to enter the url him/herself, but use their user details (such as ID, which a user cannot change themselves) to build the path, or provide a list of pre-defined locations (ignoring anything but these locations), etc.

Let me know if you hae any problems locating my old post, and I'll se if I can't find it...

ugly 31
March 07 2010, 15:28 #48216
Thank you both I will work from here.
lopezio 55
April 07 2011, 10:45 #67485
I'm completely lost.
I need to validade a username and password (in a table) and redirect the upload path to a field in my table. Any help? (I'm newbie in Joomla programming)
Thank you
lopezio 55
April 08 2011, 08:20 #67533
I think I'm close.
If I use the following code in before sending email it works
$searchpath = 'c:\delphiphp\enviar\lixo\';
$MyForm->setFormParam('uploadpath', $searchpath );

Now I only have to get a table field , or a session variable, with the path
GreyHead 65
April 08 2011, 08:35 #67534
Hi lopezio,

I built an alternative File Upload action here that allows you to add form results to the upload path using {input_name}.

Note: some of the other changes in that post have since been added to the standard File UPlaod action.

If you'd like to buy me a coffee or two, thank you very much