Replace special characters before the file is uploaded using PHP
// Get the original file name from $_FILES$file_name= $_FILES['file']['name'];// Remove any characters you don't want// The below code will remove anything that is not a-z, 0-9 or a dot.$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);
try to use this bro
$result = iconv("UTF-8", "ASCII//TRANSLIT", $text);
to know more visit how to replace special characters with the ones they're based on in PHP?
You can get the original filename for an uploaded file from $_FILES
, and you can create your "special" version by replacing characters in it with strtr
(which sounds as the best match for this case), str_replace
, preg_replace
or any other string processing function.
The best approach depends on what exactly you want to do.