Upload image in new custom folder just created

doc81 04 Dec, 2020
Hi, I see other post like this and follow the steps suggested, but I can't get the result.

I have a form with name, surname, file upload inputs.I add a custom code to create a folder with dynamic name and set the upload path:

$nome = $form->data['Nome'];$cognome = $form->data['Cognome'];
$total_name = $nome.'-'.$cognome .'-'.rand(0,1000);
$path = JPATH_SITE."/images/".$total_name;
$mode='755';

JFolder::create($path, $mode);

$form->actions_config[18]["upload_path"] = $path;

When submit form, the folder is created but the image not uploaded.
If I set the path as JPATH_SITE."/images/" the image is uploaded in this folder.

Are there any problems uploading the file to a newly created folder?

Thanks
Max_admin 04 Dec, 2020
I would suggest that you install v7, build this form in v7, and use an Upload action in the form submit event, disable the Upload files behavior in the form settings.

Then you can use your code in a PHP action above the upload action, return the $path variable, then use {var:php_name} in the Upload file path!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
doc81 04 Dec, 2020
Thank you Admin,

I'm sure this is the best solution, but my form is in a website with a lot of other forms and I should update all of them.

I would prefer to find a solution with V5.

Some ideas?
Max_admin 05 Dec, 2020
Did you try to install v7 and then use the v7 importer of v5 ? try that, if your v5 form works fine after the import then it should be an easy upgrade!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
gasoline 12 Feb, 2021
That's what I wanted to do also, but I use V6 and can't import to 7😟
Max_admin 14 Feb, 2021
Answer
use PHP to create the folder then set the path in a variable and use it in an upload action!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
mobusag 03 Nov, 2023
Hello Max
Sorry, in google search it gave me this page which is closest to my problem. i am currently using the CF8. But here the file upload is a bit different than in the previous versions. In the past I could add the folder with the name like this before the upload:
$path = '/home/frickta1/neu.mobus.ch/images/Uploads/au/' .$this->data['uploadnr'];
$mode='0755';
//echo '<script>alert("'.$path.'")</script>'; 
JFolder::create($path);


But with the CF8 I get the message that the folder does not yet exist. If I then start the upload again, the folder exists and it works. But that can't be the solution. Since I only get the folder name when I click on Submit, I cannot create a folder beforehand. Is there already a solution?

Thank you
Greetings Bambi
Max_admin 07 Nov, 2023
yes, you can not do this in v8 since the upload is processed before the "submit" section is run, your folder should be created on load, but then you need to use field data

you can use a workaround, in any of the fields BEFORE the file field, add a "Valid function" behavior, use your PHP code, but return "true"

that should do it I think
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
You need to login to be able to post a reply.

VPS & Email Hosting 20% discount
hostinger