Buy Now
Sign in

dynamic Upload path

fdnet , March 02 2017, 13:51
F
fdnet 30
March 02 2017, 13:51 #365531
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 64
March 02 2017, 14:14 #365535
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
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
F
fdnet 30
March 02 2017, 14:47 #365536
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
F
fdnet 30
March 02 2017, 15:12 #365538
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 64
March 02 2017, 18:46 #365541
 Answer
Hi Fred,

Please try again with upload_path - all lower case

Bob
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much
F
fdnet 30
March 02 2017, 19:32 #365542
It's ok now ! thanks, my god, only this mistakes...

thanks a lot. Have a goog afternoon.
F
fdnet 30
March 06 2017, 08:26 #365620
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 64
March 06 2017, 09:35 #365623
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.
ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much