if ($fileupload) {
$array_last=explode(".",$fileupload_name);
$c=count($array_last)-1;
$lastname=strtolower($array_last[$c]) ;
if (($lastname=="jpg")){
$filetype=$_FILES["fileUpload"]["type"];
if(($filetype!="image/jpg") and ($filetype!="image/jpeg") and ($filetype!="image/pjpeg") and ($filetype!="image/png") and ($filetype!="image/gif"))
{
echo "error";
}
else
{
}
// ถ้าอยากรู้ว่าไฟล์ type องไฟล์ที่เลือกมาคืออะไร ก็ลอง echo $_FILES["fileUpload"]["type"];
Date :
2010-07-07 06:46:52
By :
webmaster
No. 6
Guest
ใช้แค่วิธีของคุณวินไม่ปลอดภัยนะครับเพราะ header type นั้นสามารถปลอมแปลงได้
ต้องแปลงนามสกุลเป็น .gif หรือ .jpg ด้วยครับ