cavendano Posted October 18, 2007 Share Posted October 18, 2007 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'); } Quote Link to comment https://forums.phpfreaks.com/topic/73831-upload-script/ Share on other sites More sharing options...
clanstyles Posted October 18, 2007 Share Posted October 18, 2007 you mean the \' ? The \ is there so it knows not to execute anything. It is there because if ' was placed there it could lead to problems. Quote Link to comment https://forums.phpfreaks.com/topic/73831-upload-script/#findComment-372491 Share on other sites More sharing options...
papaface Posted October 18, 2007 Share Posted October 18, 2007 http://uk3.php.net/stripslashes Quote Link to comment https://forums.phpfreaks.com/topic/73831-upload-script/#findComment-372496 Share on other sites More sharing options...
cavendano Posted October 18, 2007 Author Share Posted October 18, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/73831-upload-script/#findComment-372506 Share on other sites More sharing options...
tibberous Posted October 18, 2007 Share Posted October 18, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/73831-upload-script/#findComment-372569 Share on other sites More sharing options...
BlueSkyIS Posted October 18, 2007 Share Posted October 18, 2007 ^^ LOL. that will be some work! <? // Remove all but letters and numbers from $string $new_string = preg_replace("/[^a-zA-Z0-9]/", "", $string); ?> Quote Link to comment https://forums.phpfreaks.com/topic/73831-upload-script/#findComment-372571 Share on other sites More sharing options...
sign guy Posted October 18, 2007 Share Posted October 18, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/73831-upload-script/#findComment-372590 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.