close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

remove commas and rename file on upload

Thread began 8/14/2012 10:45 am by Sweens | Last modified 8/14/2012 11:39 am by Sweens | 4605 views | 2 replies |

Sweens

remove commas and rename file on upload

Hi

Using UE4 file upload facilities, which works very well. An issue has just come to light when trying to do something with images that have a comma in the file name.

How can I rename files on upload so that any commas are stripped out of the filename? (It would still need to increment the file name if the same name already existed)

many thanks

Chris

Sign in to reply to this post

Jason ByrnesWebAssist

add the following code to line 1 of your page:

php:
<?php

// Code added to strip comma from uploaded file name
if(isset($_FILES['fileField']['name'])) { 
$_FILES['fileField']['name'] = str_replace(",","",$_FILES['fileField']['name']); 

?>



replace fileField with the name of your file field.

Sign in to reply to this post

Sweens

thanks Jason - works a treat.

Sign in to reply to this post

art226587

I have to strip out apostrophes (') and this solved my filename problem. But now the user isn't redirected to the correct page upon insert complete ($WA_redirectURL = "thanks.php";). The same form page just reloads even though the data is being captured and the filenames are rewritten correctly. Please help!

Sign in to reply to this post

Jason ByrnesWebAssist

most likely an error is occuring to prevent the redirect.

to turn error reporting on, add the following code at line 1:

php:
<?php

error_reporting
(E_ALL);
ini_set('display_errors','on');
?>



once we know what the error is, we will be able to troubleshoot the cause.

most likely the error is the Headers already sent error which can be caused by a space at the end of a closing php tag:
?> "

or a blank line between the closing php and an opening php tag:
?>

<?php


see this thread for details:
showthread.php?t=19285

Sign in to reply to this post

art226587

Thanks, Jason. I reverted back to an earlier version of the file and now it's working.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...