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
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
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!
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!
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?
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?
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!
use PHP to create the folder then set the path in a variable and use it in an upload action!
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:
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
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
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
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
You need to login to be able to post a reply.