ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

dynamic Upload path

fdnet 02 Mar, 2017
Hi every body,

I have a form in which the user enters a gallery name. I also have a "File Field" which allows him to deposit pictures.

In the list of events I have a "Files upload" who save the photos in a directory.
I want to use the name of the gallery to create the directory dynamically and to save the photos there.

I put the code in a custom code and it's ok :
<?php
$path = 'images/phocagallery/' . $form->data['title'];
$mode='755';
JFolder::create($path, $mode);
?>

But, i really don't know how to put the $path in the "Upload path" of my Files Upload...
i test this but it doesn't work : $form->actions_config[1]['Upload_path'] = $path

I search in the forum but, i really don't find.
Thanks a lot for your help.🙂
Fred
GreyHead 02 Mar, 2017
Hi Fred,

This version has the absolute path - not a relative one - and should work OK
<?php
$path = JPATH_SITE.'/images/phocagallery/'.$form->data['title'];
$mode='755';
JFolder::create($path, $mode);
$form->actions_config[1]['Upload_path'] = $path;
?>
Or you can upload the file to a temporary folder then use a Custom Code action to rename and move it.

Bob
fdnet 02 Mar, 2017
Hi Bob,

the code
$path = 'images/phocagallery/' . $form->data['title'];
$mode='755';
JFolder::create($path, $mode);

Work very well the directory is created and ok.

the code
$form->actions_config[1]['Upload_path'] = $path 

don't work. The photos is not upload in the directory...i think it is this code "$form->actions_config[1]['Upload_path']"
Because when i write the path directly in the parameter of my Files Upload, it work.

I search. 🤣
Fred
fdnet 02 Mar, 2017
Some additions: I modified the code to integrate the id of my field Field Upload Action.
$form->actions_config[13]['Upload_path'] = $path

But it doesn't work.
GreyHead 02 Mar, 2017
Answer
Hi Fred,

Please try again with upload_path - all lower case

Bob
fdnet 02 Mar, 2017
It's ok now ! thanks, my god, only this mistakes...😑

thanks a lot. Have a goog afternoon.
fdnet 06 Mar, 2017
Hi bob,
I don't know why but it doesn't work again...
The directory is créate = ok
But the photos is in the Chronoforms uploads/form_name/ directory but not in my dynamic directory...

My custom code is before the files upload.

<?php
$path = 'images/phocagallery/' . $form->data['title'];
$mode='755';
JFolder::create($path, $mode);
$form->actions_config[13]['upload_path'] = $path;
?>

Do you see sommething wrong ? thanks😢
GreyHead 06 Mar, 2017
Hi fdnet,

The path needs to be absolute - please see my earlier post.

Check that 13 is still the Action ID for the Files Upload action

Add some debugger code to see that the value of $path is being set as.
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com