Jump to content

upload script


cavendano

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.