www.julianstricker.com - Home

User login

julianstricker's tweets

  • last.fm now runs great on my HTC Hero :-) 1 week 5 days ago
  • @splattne Kingston ssdNOW V+ SNVP325-S2 2 weeks 5 days ago
  • Mein Acer 8942G bootet dank neuer SSD in nur 9 Sekunden 2 weeks 6 days ago
  • Buzz lebt!!! 3 weeks 6 days ago
  • mein Acer Aspire 8942G ist angekommen :-) 6 weeks 2 days ago

Filter filename on fileupload and prevent execution of uploaded files

Its a good way to allways rename uploaded files using something like a MD5-hash and store the original filename in a database.

If for some reason you dont want to rename it using a hash, you should filter the filename using some code like this one:

$filename = strip_tags($_FILES["upload"]["name"]);
$filename = str_replace(array('|','<','>','"','\'',':','\\','/','*','?'),'',$filename); 

It's a good idea to deny the execution of all uploaded files: place a .htaccess file in your upload-directory:

RemoveHandler .cgi .shtm .shtml
RemoveType .php .php3 .php4 .php5

deny from all


order deny,allow
deny from all



follow me on Twitter

Certificates

php5-zce-logo-new

www.julianstricker.com feeds