|
 |
|
มีปัญหาตอนอัพรูปครับ รบกวนช่วยดูโค้ดให้ด้วยครับ มันเป็นตอน Add หนะครับ |
|
 |
|
|
 |
 |
|
มีปัญหาตอนอัพรูปครับ รบกวนช่วยดูโค้ดให้ด้วยครับ มันเป็นตอน Add หนะครับ
ปัญหาคือ มันจะบอกว่าไฟล์นี้ไม่อนุญาตตลอดครับ ไม่รู้พลาดตรงไหน รบกวนด้วยครับ
Code (PHP)
<?
if(isset($_POST['date'])){
//variable
$addcat=mysql_insert_id().$_POST['addcat'];
$pro_code=$_POST['code_pro'];
$pro_name=$_POST['cat_name'];
$qstock=$_POST['qstock'];
$price=$_POST['price'];
$price_member=$_POST['price_member'];
$pro_status=$_POST['Status_pro'];
$date_today=$_POST['date'];
//upload single file
if($_FILES['fileupload']['error']==0)
{
//Type Allow
if((($_FILES['fileupload']['type']=="image/pjpeg")
||($_FILES['fileupload']['type']=="image/jpg")
||($_FILES['fileupload']['type']=="image/gif")
||($_FILES['fileupload']['type']=="image/png"))
&&($_FILES['fileupload']['size']<200000)) //1kb=1mb
{
//upload & Resize
if(trim($_FILES["fileupload"]["tmp_name"]) != "")
{
$rand=time();
$images = $_FILES["fileupload"]["tmp_name"];
$new_images = "Thumbnail_".$_FILES["fileupload"]["name"];
move_uploaded_file($_FILES["fileupload"]["tmp_name"],"../uploads/product/".$_FILES["fileupload"]["name"]);
//Resize
$width=106; //*** Fix Width & Heigh (Auto caculate) ***//
$size=GetimageSize($images);
$height=round($width*$size[1]/$size[0]);
$images_orig = ImageCreateFromJPEG($images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
$img=$rand."_".$images;
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
ImageJPEG($images_fin,"../uploads/product/".$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
}
}else{
msgbox("file type not allow");
redirect("product.php");
}
}
//Add to DB
$sql="INSERT INTO tb_product";
$sql.="(CAT_ID,CODE,NAMEBOOK,CHECKSTOCK,PRICE,PRICE_MEMBER,STATUS,IMGBOOK,DATE_TODAY)";
$sql.="VALUES ('$addcat','$pro_code','$pro_name','$qstock','$price','$price_member','$pro_status','$img','$date_today')";
$rs=mysql_query($sql)or die (mysql_error());
echo"sql : ".$sql;
if($rs){
redirect("product.php");
}else{
msgbox("Don't Success");
}
}//if

Tag : PHP

|
|
 |
 |
 |
 |
Date :
2011-01-05 14:34:17 |
By :
nottpoo |
View :
1078 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
if($_FILES['fileupload']['error']==0)
ดู if ให้ดี ๆ ครับ 
|
 |
 |
 |
 |
Date :
2011-01-05 15:25:25 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ครับ ทำได้ละครับพี่วิน
|
 |
 |
 |
 |
Date :
2011-01-06 09:27:29 |
By :
nottpoo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|