Hi, I am trying to create a customer manager for s shop for an intranet app. Im trying to use the chronoforms uplod action, and its working ok, but I want to upload to the folder created for the user when they sign up. I have written a php script to create a folder for each customer ID when the customer is created. The shop owner then opens each customer and adds files to the directories.
The folders created are named by the cf id so for example root/customer-files/1 would be the folder for the customer Jack Smith. What I need to do is when someone loads Jack Smiths customer record up or any other record the file upload path is dynamically updated so that the files are uploaded to root/customer-files/1 instead of to a static directory.
Can this be done with Chrono or will I have to code this one ?.
Thanks🙂
Hi bob, I tried using yours too with a curly bracket {cf_id} at the end of the path but just end up with a folder called {cf_id} instead of the number, iv got the curly brackets replacer turned on in show HTML too :-( .
Hi crea2k,
And how are you setting the value of cf_id?
Please drag a Debugger action into the On Submit event, then submit the form and post the debug results here. Note: if you are using the Easy Wizard you may need to switch to the Advanced Wizard to do this; if you want to continue to use the Easy Wizard please make a copy of your form first and add the Debugger action to the copy.
Bob
I am using GET to pull it from the previous page, which is a list of customers, when the shop hits edit it puts the cf_id into get and passes it onto the next page where it puts it into a hidden cf_id field. I also put it into a string $cfid , if I echo $cfid; it echo's out the customers ID, so presumably if I use {cfid} in the path name it should work ?, or can I use $cfid ?.
Hi crea2k,
I don't think that you can use PHP in there, so probably <?php echo $cfid; ?> won't work .
If you have the value in a hidden input with the name cf_id then it should be picked up OK.
Please drag a Debugger action into the On Submit event, then submit the form and post the debug results here.
Bob
Hi Bob, I have fixed it now !, I didn't put in a file name, the reason I didn't put in a file name though, was because I wanted to keep the original file name in there otherwise I cant tell what file is what. Is this possible ?, also some of the files could have non standard names with spaces in etc, I know you can strip these with preg_replace etc, and something similar is in the original uploader but there doesn't seem to be an option in yours ?.
Thanks Bob, which of the two files does this need to go in, and where abouts ?.
Thanks🙂
Also is it possible to not set a file name, so that it keeps the original file name, as when I add files at the min they are all called the same thingface-meh-blank
Hi crea2k,
Yes, just use {input_name} with the name of the file upload input I think. The risk with this is that files with the same name will over-write each other.
Bob
Thanks Bob, that's ok, that's what I want it to do anyway. Where abouts should I add your above edits for the file name sanitising ?.
Hi Bob, if I use {input_name} it just names my files input_name , I have also tried {customeraddnewfile} which is the field name but some across the same problem/
I have turned on debug and get the following :
Data Array:
Array
(
[option] => com_chronoforms
[customerID] => 36904f703fb6df48d7.40712320
[cfid] => 5
[chronoform] => EditCustomer
[event] => submit
[Itemid] =>
[customertitle] => Mr
[customerfirstname] => Will
[customersurname] => Simpson
[customercompanyname] => Simpson Arboriculture
[customerbuildinghousenamenumber] => Tree House
[customertown] => Ancaster
[customerstreet] => Tree Lane
[customercounty] => Lincolnshire
[customerpostcode] => NG32 345
[customertelephone] => 01400 258745
[customermobile] => 08566 547554
[customerfax] =>
[customeremail] => [email]enquiries@simparb.co.uk[/email]
[cf_uid] => 0dee5662ba996401943ce288c2b00df4
[cf_id] => 5
[submit] => Submit
[e420343b986c2ee4c5be39a838c617cc] => 1
[customeraddnewfile] => input_name.jpg
[customeraddnewfile_size] => 800
[customeraddnewfile_url] => ./customer-files/5/input_name.jpg
[customeraddnewfile_path] => .\customer-files\5\input_name.jpg
[_PLUGINS_] => Array
(
[upload_files] => Array
(
[customeraddnewfile] => Array
(
[name] => input_name.jpg
[path] => .\customer-files\5\input_name.jpg
[size] => 818985
[link] => ./customer-files/5/input_name.jpg
)
)
)
[chronoform_data] => Array
(
[cf_modified] => 2012-03-27 14:19:19
[option] => com_chronoforms
[customerID] => 36904f703fb6df48d7.40712320
[cfid] => 5
[chronoform] => EditCustomer
[event] => submit
[Itemid] =>
[customertitle] => Mr
[customerfirstname] => Will
[customersurname] => Simpson
[customercompanyname] => Simpson Arboriculture
[customerbuildinghousenamenumber] => Tree House
[customertown] => Ancaster
[customerstreet] => Tree Lane
[customercounty] => Lincolnshire
[customerpostcode] => NG32 345
[customertelephone] => 01400 258745
[customermobile] => 08566 547554
[customerfax] =>
[customeremail] => [email]enquiries@simparb.co.uk[/email]
[cf_uid] => 0dee5662ba996401943ce288c2b00df4
[cf_id] => 5
[submit] => Submit
[e420343b986c2ee4c5be39a838c617cc] => 1
[customeraddnewfile] => input_name.jpg
[customeraddnewfile_size] => 800
[customeraddnewfile_url] => ./customer-files/5/input_name.jpg
[customeraddnewfile_path] => .\customer-files\5\input_name.jpg
[_PLUGINS_] => Array
(
[upload_files] => Array
(
[customeraddnewfile] => Array
(
[name] => input_name.jpg
[path] => .\customer-files\5\input_name.jpg
[size] => 818985
[link] => ./customer-files/5/input_name.jpg
)
)
)
)
[chronoform_data_cf_id] => 5
)
Validation Errors:
Array
(
)
Debug Data
Upload files
File post array: Array ( [name] => 070920093671.jpg [type] => image/jpeg [tmp_name] => C:\Users\Iain\AppData\Local\Temp\php24C3.tmp [error] => 0 [size] => 818985 )
Upload routine started for file upload by: customeraddnewfile
Success: input_name.jpg has been uploaded OK.
File size is 800 kb
File path is:
.\customer-files\5\input_name.jpg
File url is:
./customer-files/5/input_name.jpg