Dynamically setting image upload path

ugly 05 Mar, 2010
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 05 Mar, 2010
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.

Bob
nml375 05 Mar, 2010
Hi,
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...

/Fredrik
ugly 07 Mar, 2010
Thank you both I will work from here.
lopezio 07 Apr, 2011
Friends
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 08 Apr, 2011
Hi
I think I'm close.
If I use the following code in before sending email it works
<?php
$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 08 Apr, 2011
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.

Bob
This topic is locked and no more replies can be posted.