Code: Select all
<input type="file" name="file" size="30">upload file
Code: Select all
// ==============
// Configuration
// ==============
$uploaddir = "uploads"; // Where you want the files to upload to - Important: Make sure this folders permissions is 0777!
$allowed_ext = "jpg, gif, png, pdf"; // These are the allowed extensions of the files that are uploaded
$max_size = "5000000"; // 50000 is the same as 50kb
$max_height = "800"; // This is in pixels - Leave this field empty if you don't want to upload images
$max_width = "800"; // This is in pixels - Leave this field empty if you don't want to upload images
// Check Entension
$extension = pathinfo($_FILESї'file']ї'name']);
$extension = $extensionїextension];
$allowed_paths = explode(", ", $allowed_ext);
for($i = 0; $i < count($allowed_paths); $i++) {
if ($allowed_pathsї$i] == "$extension") {
$ok = "1";
}
}
// Check File Size
if ($ok == "1") {
if($_FILESї'file']ї'size'] > $max_size)
{
print "File size is too big!";
exit;
}
// Check Height & Width
if ($max_width && $max_height) {
list($width, $height, $type, $w) = getimagesize($_FILESї'file']ї'tmp_name']);
if($width > $max_width || $height > $max_height)
{
print "File height and/or width are too big!";
exit;
}
}
// The Upload Part
if(is_uploaded_file($_FILESї'file']ї'tmp_name']))
{
move_uploaded_file($_FILESї'file']ї'tmp_name'],$uploaddir.'/'.$_FILESї'file']ї'name']);
}
print "Your file has been uploaded successfully! Yay!";
} else {
print "Incorrect file extension!";
}
echo "done";
exit;by using above system: i m getting this as output:
----------
Incorrect file extension!done