I was wondering if it is possible to change the name of the file to be uploaded. I mean what I am trying to do is that, the user uploads a file which may have some special characters like special characters in some European languages.
What I am planning to do is that before using the move_uploaded_file command is it possible to change/preg_replace the special characters with normal characters, so that the file is uploaded and stored with the new name which has only normal characters.
try to use this bro
to know more visit how to replace special characters with the ones they're based on in PHP?
Also you can use a function for special characters like this:
Be carefull about allow . for file extension.
And then change your original temp file name,
You could do it like this, write a simple function
strip_special_chars()
to replace characters you want in a stringYou can get the original filename for an uploaded file from
$_FILES
, and you can create your "special" version by replacing characters in it withstrtr
(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.