|
|
|
ขอcode ตรวจสอบว่าไฟล์ที่เราuploadมาเป็นไฟล์รูปภาพหรือว่าค่ะ |
|
|
|
|
|
|
|
Code (PHP)
<?php
if (($picture!=none) && (ereg("^image",$picture_type) || ereg("application/x-shockwave-flash",$picture_type))) { // check image type
$picture_path="./picture_comment"; // path file to be saved
# print "Local File : $picture <br>\n"; // file image detail
print "File name : $picture_name <br>\n"; // file image detail
printf ("Size : %d",($picture_size/1024)); // file image detail
print " KB. <br>\n";
print "Type : $picture_type <br>\n"; // file image detail
if ($picture_type=="image/gif") { // check image type
$imgtype="gif";
}
elseif (($picture_type=="image/pjpeg") || ($picture_type=="image/jpeg")) { // IE & Firefox
$imgtype="jpg";
}
elseif ($picture_type=="image/png") {
$imgtype="png";
}
elseif ($picture_type=="application/x-shockwave-flash") {
$imgtype="swf";
}
elseif ($picture_type=="image/bmp") {
$imgtype="bmp";
}
else {
$imgtype="";
}
$picture_name_new=time().".$imgtype"; // set image name
if (copy($picture,"$picture_path/$picture_name_new")) { // coppy image
# print "ÀÒ¾»ÃСͺ : $picture_name_new <br>\n"; // ok
}
else {
print "äÁèÊÒÁÒöãÊèÀÒ¾»ÃСͺä´é <br>\n"; // no ok
}
# Unlink picture from Temp
unlink ($picture);
$picture="$picture_name_new";
}
else {
if ($picture_name=="") {
print "äÁèÁÕÀÒ¾»ÃСͺ <br>\n";
}
elseif (!ereg("^image",$picture_type) || !ereg("application/x-shockwave-flash",$picture_type)) {
print "äÁèãªè image file ËÃ×Í flash file<br>\n";
}
else {
print "ÀÒ¾»ÃСͺ¢¹Ò´à¡Ô¹ 150 Kb <br>\n";
}
$picture="";
}
# End Upload picture
?>
ก้อบรูปที่เลือก ลงโฟลเดอร์
?>
|
|
|
|
|
Date :
2009-10-01 14:05:14 |
By :
Sek-Artdrinker |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|