I need to know how to remove spaces from a file for upload. When I link using the file name with spaces the link is sometimes broken. Spaces also need to be removed from the data loaded into the mysql database.
Forums
Remove spaces from uploaded files name.
Hi edebeer,
You can probably do it by urlencoding the name, or by using a string replace to take out spaces.
Alternatively I guess it might be possible to add validation the the file upload box to disallow spaces there.
Bob
You can probably do it by urlencoding the name, or by using a string replace to take out spaces.
Alternatively I guess it might be possible to add validation the the file upload box to disallow spaces there.
Bob
I was able to remove the space with the attached code, but only for the name saved in the database how do I change the name of the uploaded file? The code was placed in On Success in Upload File.
<?php
$form->data['photo']= str_replace(" ","_",$form->data['photo']);
?>
Hi edebeer,
Well, yes that's running after the file is uploaded so you'd need to rename the file.
You might want to try my Upload File [GH] action that will let you use data from the form in the file name box so you could use a Custom Code action to create a urlencoded version of the file name, save it to the $form->data array and use that.
Bob
PS I'll look at adding a simple name cleaner into the action but it won't be today :-(
Well, yes that's running after the file is uploaded so you'd need to rename the file.
You might want to try my Upload File [GH] action that will let you use data from the form in the file name box so you could use a Custom Code action to create a urlencoded version of the file name, save it to the $form->data array and use that.
Bob
PS I'll look at adding a simple name cleaner into the action but it won't be today :-(
Just one problem - I am using the new image resizer and there is no on success area to load it in. Anyway to make this work.
I tried using Upload File [GH] action, instead I did the following.
I hacked upload_files.php on around line 82 I added:
Is this ok or does it mess something up?
I hacked upload_files.php on around line 82 I added:
$file_name= str_replace(" ","_",$file_name);
Is this ok or does it mess something up?
Hi edebeer,
That's fine as a workaround. Make a note for yourself that it will break when you next upgrade ChronoForms to a new release.
Bob
That's fine as a workaround. Make a note for yourself that it will break when you next upgrade ChronoForms to a new release.
Bob
This topic is locked and no more replies can be posted.