<?php
$uploaddir="uploads/images";
$allowed_ext="jpg, gif, png";
$max_size="500000";
$max_height="2000";
$max_width="2000";
//Check extension
$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"Yor file is too big!";
exit;
}
//Check Length & Width
if ($max_width && $max_height) {
list($width, $hieght, $type, $w)=
getimagesize($_FILES['file']['tmp_name']);
if($width > $max_height || $height > $max_height)
{
print"File height/width is too big!";
exit;
}
}
//Upload part
if(is_uploaded_file($_FILES['file']['tmp_name']))
{
move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);
}
print"Your file uploaded successfully! Cookie?";
}else{
print"Wrong file extension, BRO.";
}
?>
My problem is that under: $allowed_ext="jpg, gif, png";
When I try to upload, it only accepts .jpg file extension -.-
Could someone help me figure out how to get the other file extensions accessible?