Revision: 32802
Updated Code
at February 26, 2011 19:21 by mikael12
Updated Code
if($_FILES['image']['name'] != '')
{
$filename = preg_replace('/[^a-zA-Z0-9._-]/', '', $_FILES['image']['name']);
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
if (! preg_match('/\.(jpg|gif|png)/i', $ext))
echo 'Filetype not supported.';
if ($_FILES['image']['size'] > 1000000)
echo 'File size too high, 1MB is allowed.';
move_uploaded_file($_FILES['image']['tmp_name'], PATH . '/'.$filename);
}
Revision: 32801
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 2, 2010 06:35 by mikael12
Initial Code
if($_FILES['image']['name'] != '')
{
$filename = preg_replace('/[^a-zA-Z0-9._-]/', '', $_FILES['image']['name']);
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1);
if (preg_match('/\.(jpg|gif|png)/i', $ext))
echo 'Filetype not supported.';
if ($_FILES['image']['size'] > 1000000)
echo 'File size too high, 1MB is allowed.';
move_uploaded_file($_FILES['image']['tmp_name'], $path.'/'.$filename);
}
Initial URL
Initial Description
form enctype="multipart/form-data"
Initial Title
PHP file upload with extension and size check
Initial Tags
Initial Language
PHP