คือผมกำลังทำให้เมื่อเราอัพโหลดไฟล์ไปแล้วมันแยกหมวดหมู่ให้จากนามสกุลที่อัพโหลดเลยน่ะครับ
แต่ทำไปทำทำมา งง มันดันเข้าอีกเงื่อนไขตลอดเลย ท่านใดว่าง ช่วยผมเชคทีนะครับ ตาลายมากเลย
<?php
if($_GET[action]=='add'){
if(move_uploaded_file($_FILES["upload"]["tmp_name"],"upload/".$_FILES["upload"]["name"]))
{
if(trim($_FILES["poster"]["tmp_name"]) != "")
{
$typeupload = $_FILES['poster']['type'];
$images = "poster/".$_FILES["poster"]["name"]."";
$new_images = "Poster_".$_FILES["poster"]["name"];
copy($_FILES["poster"]["tmp_name"],"poster/".$_FILES["poster"]["name"]);
$width=300; //*** Fix Width & Heigh (Autu caculate)
$height=200;
//$size=GetimageSize($images);
//$height=round($width*$size[1]/$size[0]);
if ($typeupload =="image/pjpeg"|| $typeupload =="image/jpg" || $typeupload =="image/jpeg" || $typeupload =="image/JPG" ){
$images_orig = ImageCreateFromJPEG($images);
}
if ($typeupload =="image/gif"|| $typeupload =="image/GIF"){
$images_orig = ImageCreateFromgif($images);
}
if ($typeupload =="image/png"|| $typeupload =="image/x-png"){
$images_orig = ImageCreateFrompng($images);
}
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
ImageJPEG($images_fin,"poster/".$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
@unlink("$images");
}
$cate=$_FILES["upload"]["name"];
$cate=strtolower($cate);
$fty=array(".gif",".png",".jpg",".jpeg","txt",".pdf",".doc",".docx",".ppt",".pptx",".xlsx",".xls",".zip",".rar",".mp3",".wmv",".mp4",".avi",".mkv",".mpg");
for($i=0;$i<strlen($fty);$i++){
if(strrpos($cate,$fty[$i])>=0){
$b=substr($cate,strrpos($cate,$fty[$i]),strlen($cate));
if($b=='.wmv'||$b=='.mp4'||$b=='.avi'||$b=='.mkv'||$b=='.mpg'){$category=1;}
else if($b=='.mp3'){$category=2;}
else if($b=='.gif'||$b=='.png'||$b=='.jpg'||$b=='.jpeg'){$category=3;}
else if($b=='.txt'||$b=='.pdf'||$b=='.doc'||$b=='.docx'||$b=='.ppt'||$b=='.pptx'||$b=='.xlsx'||$b=='.xls'){$category=4;}
else {$category=5;}
}
}
$modre = str_replace(" ", "-", $_POST[name]);
$strSQL = "INSERT INTO content ";
$strSQL .="(category_id,name,poster,post_date,modre,filesname) VALUES ('$category','".$_POST["name"]."','$new_images','$todaydate','$modre','".$_FILES["upload"]["name"]."')";
$objQuery = mysql_query($strSQL);
if($objQuery){header("Location: index.php?page=upload&status=added");}
}
}
?>
ช่วยหน่อยนะครับ
