Jump to content

Recommended Posts

I have an upload script that works great except for when a file with special characters is used.

If  eric'sfile.txt is uploaded it will do this  eric\'sfile.txt  is there a way to have it remove the special characters instead?

 

//path to storage
$storage = 'Files';

//path name of file for storage
$uploadfile = "$storage/" . basename( $_FILES['Filedata']['name'] );

//if the file is moved successfully
if ( move_uploaded_file( $_FILES['Filedata']['tmp_name'] , $uploadfile ) ) {
echo( '1 ' . $_FILES['Filedata']['name']);

//file failed to move
}else{
echo( '0');
}

Link to comment
https://forums.phpfreaks.com/topic/73831-upload-script/
Share on other sites

thanks papaface but what I was asking is if when the file is uploaded as  eric'sfile.txt the script would rename it and call it ericsfile.txt instead...remove any special characters.

 

$name = str_replace("'", "", $name);

$name = str_replace("!", "", $name);

$name = str_replace("@", "", $name);

$name = str_replace("#" "", $name);

$name = str_replace(",", "", $name);

$name = str_replace("-", "", $name);

$name = str_replace("=", "", $name);

$name = str_replace("\\", "", $name);

$name = str_replace(" ", "", $name);

 

 

Just keep doing those.

Link to comment
https://forums.phpfreaks.com/topic/73831-upload-script/#findComment-372569
Share on other sites

hey cavendano,  would you mind giving me a hand with my file upload script.  i am very new to all this and just need help getting my server setup to except uploads. I have the basic php page ready for all this http://www.westcoastvinylsigns.com/quote.php now i just need to insert some coding i think? :)

Link to comment
https://forums.phpfreaks.com/topic/73831-upload-script/#findComment-372590
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.