|
|
|
โค้ดอัพโหลด อัพโหลดรูปไม่ได้ ช่วยที่คับ copy($_FILES['fileupload']["tmp_name"],$_FILES['fileupload']["name"]); |
|
|
|
|
|
|
|
โค้ดอัพโหลด
<?php
$product_name=$_POST[product_name];
$brand=$_POST[brand];
$detail=$_POST[detail];
$price=$_POST[price];
$unitstock=$_POST[unitstock];
$ref_id_type=$_POST[ref_id_type];
$fileupload=$_FILES['fileupload'] ['tmp_name'];
$fileupload_name=$_FILES['fileupload'] ['name'];
$fileupload_size=$_FILES['fileupload'] ['size'];
$fileupload_type=$_FILES['fileupload'] ['type'];
include "../check.php";
if($product_name=="" ) {
msg("¡ÃسҡÃÍ¡ª×èÍÊÔ¹¤éÒ´éÇÂ");
}
else if($ref_id_type=="0"){
msg("¡ÃسÒàÅ×Í¡»ÃÐàÀ·ÊÔ¹¤éÒ´éÇÂ");
}
else if($brand==""){
msg("¡ÃسҡÃÍ¡áºÃ¹´ìÊÔ¹¤éÒ´éÇÂ");
}
else if($price==""){
msg("¡ÃسҡÃÍ¡ÃÒ¤ÒÊÔ¹¤éÒ´éÇÂ");
}
else if($unitstock==""){
msg("¡ÃسҡÃÍ¡¨Ó¹Ç¹ÊÔ¹¤éÒ´éÇÂ");
}
include "../connect.php";
$sql="insert into product (product_name,brand,detail,price,ref_id_type,unitstock)values('$product_name','$brand','$detail','$price','$ref_id_type','$unitstock')";
$result=mysql_db_query($dbname,$sql) or die(mysql_error());
if($fileupload){
$array_last=explode(".",$fileupload_name);
$c=count($array_last)-1;
$lastname=strtolower($array_last[$c]);
if($lastname=="gif" or $lastname=="jpg" or $lastname=="jpeg"){
$sql2="select max(product_id) from product";
$result2=mysql_db_query($dbname,$sql2);
$row=mysql_fetch_row($result2);
$photoname=$row[0].".".$lastname;
copy($fileupload,"../images/".$photoname);
$sql3="update product set picture='$photoname' where product_id='$row[0]'";
$result3=mysql_db_query($dbname,$sql3);
}
unlink($fileupload);
}
header("Location: add_product.php");
mysql_close();
?>
Tag : - - - -
|
|
|
|
|
|
Date :
2009-11-05 11:29:51 |
By :
buza |
View :
1979 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลอง
Code (PHP)
print_r($_FILES['fileupload']);
ว่ามีค่าหรือไม่
หรือลอง code ง่าย ๆ ครับ
Code (PHP)
copy($_FILES['fileupload']["tmp_name"],$_FILES['fileupload']["name"]);
|
|
|
|
|
Date :
2009-11-05 11:41:37 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณ MR.WIN มากนะคะ แก้ปัญหาของเราได้เพราะคำตอบนี้เลยค่ะ
|
|
|
|
|
Date :
2009-12-14 11:02:01 |
By :
nanoSnaiL |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|