file uploads with special characters in php

Subject:

special characters like # can cause some interesting and problematics with your code.  You need to remove them.references: http://stackoverflow.com/questions/9838994/replace-special-characters-before-the-file-is-uploaded-using-php

2015-04-01 17:52:40gstlouis

// Get the original file name from $_FILES
$file_name= $_FILES['file']['name'];

// Remove any characters you dont want
// The below code will remove anything that is not a-z or 0-9
$file_name = preg_replace("/[^a-zA-Z0-9]/", "", $file_name);

// Get the location of the folder to upload into
$location = 'path/to/dir/';

// Use move_uploaded_file()
move_uploaded_file($_FILES["file"]["tmp_name"], $location.$file_name);

gstlouis
vote
2015-04-01 17:52:57