|
 |
|
สอบถามท่านผู้รู้ครับ ช่วยทีงมหลายวันแล้วเรื่องการอัพโหลดภาพครับ |
|
 |
|
|
 |
 |
|
สวัสดีคับ คือผมต้องการให้ มีการแก้ไขข้อมูล แล้วรูปภาพไม่ได้เลือกรูปใหม่ เวลาบันทึก อยากให้ยังเก็บข้อมูลภาพเดิมเอาไว้ตรง ของผมเวลาแก้ข้อมูล แล้วบันทึก ภาพก็จะหายไปน่ะคับ ต้องเพิ่มเติมโค๊ดอะไร ตรงไหนครับ บอกทีครับ
Code (PHP)
<?php
ob_start();
include_once"../connect.php";
/////image properties/////
$pro_file_tmp=$_FILES['pro_file']['tmp_name'];
$pro_file_name=$_FILES['pro_file']['name'];
////uploadfile/////
move_uploaded_file($pro_file_tmp,"../uploads/$pro_file_name");
//////
$pro_name=$_POST['pro_name'];
$pro_detail=$_POST['pro_detail'];
$pro_price=$_POST['pro_price'];
$pro_id=$_POST['pro_id'];
if(empty($pro_id)){
$sql="INSERT INTO tb_promotion (pro_image,pro_name,pro_detail,pro_price,pro_date) VALUES ('$pro_file_name','$pro_name','$pro_detail','$pro_price',NOW())";
}
else{
$sql="UPDATE tb_promotion SET pro_image='$pro_file_name',pro_name='$pro_name',pro_detail='$pro_detail',pro_price='$pro_price' WHERE pro_id='$pro_id' ";
}
if(mysql_query($sql)){
header("location:main.php?url=manage_promotion.php");
}else{
echo mysql_error();
}
?>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2011-04-21 23:38:26 |
By :
dekchai |
View :
631 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาแบบง่ายๆ นะครับ ไม่ต้องแก้อะไรเยอะ
<?php
ob_start();
include_once"../connect.php";
/////image properties/////
$pro_file_tmp=$_FILES['pro_file']['tmp_name'];
$pro_file_name=$_FILES['pro_file']['name'];
////uploadfile/////
move_uploaded_file($pro_file_tmp,"../uploads/$pro_file_name");
//////
$pro_name=$_POST['pro_name'];
$pro_detail=$_POST['pro_detail'];
$pro_price=$_POST['pro_price'];
$pro_id=$_POST['pro_id'];
if(empty($pro_id)){
$sql="INSERT INTO tb_promotion (pro_image,pro_name,pro_detail,pro_price,pro_date) VALUES ('$pro_file_name','$pro_name','$pro_detail','$pro_price',NOW())";
}
else{
if(!empty($pro_file_name)){
$sql="UPDATE tb_promotion SET pro_image='$pro_file_name',pro_name='$pro_name',pro_detail='$pro_detail',pro_price='$pro_price' WHERE pro_id='$pro_id' ";
}else{
$sql="UPDATE tb_promotion SET pro_name='$pro_name',pro_detail='$pro_detail',pro_price='$pro_price' WHERE pro_id='$pro_id' ";
}
}
if(mysql_query($sql)){
header("location:main.php?url=manage_promotion.php");
}else{
echo mysql_error();
}
?>
|
 |
 |
 |
 |
Date :
2011-04-21 23:45:55 |
By :
PlaKriM |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|