php - uploading the name of the images -


i'm uploading name of images database!

the problem name in database blank space before name!

where problem?

$original_name = strtolower(trim($arquivo['name'])); $caracteres = array("ç","~","^","]","[","{","}",";",":","´",",",">",                    "<","-","/","|","@","$","%","ã","â","á","à","é",                   "è","ó","§","ò","+","=","*","&","(",")","!","#","?",                   "`","ã"," ","©","£");  $original_name = str_replace(' ', '', $original_name); $final_name = str_replace($caracteres,"",$original_name); 

i suggest use white list of allowed characters such [a-za-z0-9_]

and use:

$final_name = preg_replace("#[^a-z0-9_]+#i", "", $arquivo['name']); 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -