ช่วยดูให้หน่อยครับ พออัพโหลดรูปภาพไป โดยที่รูปภาพไม่เกิน 512 k แล้วทำไมมันไปเงื่อนไข else
Code (PHP)
<?php
include"chkbrowser.php";
$name=$_POST[name];
$title=$_POST[title];
$fileupload=$_FILES['fileupload']['tmp_name'];
$fileupload_name=$_FILES['fileupload']['name'];
$fileupload_size=$_FILES['fileupload']['size'];
$fileupload_type=$_FILES['fileupload']['type'];
$sql="insert into slider values('','','$title')";
$result=mysql_db_query($dbname,$sql);
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" or $lastname=="png") {
$sql2="select max(id_slider) from slider ";
$result2=mysql_db_query($dbname,$sql2);
$row=mysql_fetch_row($result2);
$photoname=$name.".".$lastname;
copy($fileupload,"images/slideshow/".$photoname);
$sql3="update slider set name_slider='$photoname' where id_slider ='$row[0]' ";
$result3=mysql_db_query($dbname,$sql3);
}
unlink($fileupload);
}
if ($result&$result3) {
echo "<script>alert(' Upload Finish ');</script>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0.1;URL=admin_slider.php\">"; exit();
} else {
$sql4="select max(id_slider) from slider ";
$result4=mysql_db_query($dbname,$sql4);
$row2=mysql_fetch_row($result4);
$sql5="delete from slider where id_slider='$row2[0]' ";
$result5=mysql_db_query($dbname,$sql5);
echo "<script>alert(' Error Picture over 512 K. ');</script>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0.1;URL=admin_slider.php\">"; exit();
}
mysql_close();
?>
Tag : PHP, MySQL, HTML/CSS, JavaScript
Date :
2013-01-17 14:57:31
By :
konhuafu.it
View :
980
Reply :
4
รูปลง folder slideshow รึป่าวครับ แล้วมัน insert ลง database มั้ย
Date :
2013-01-17 15:26:39
By :
teez1232002
ถ้าไม่ if result3 ข้อมูลลงครับ สงสัยติดปัญหาตรง
Code (PHP)
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" or $lastname=="png") {
$sql2="select max(id_slider) from slider ";
$result2=mysql_db_query($dbname,$sql2);
$row=mysql_fetch_row($result2);
$photoname=$name.".".$lastname;
copy($fileupload,"images/slideshow/".$photoname);
$sql3="update slider set name_slider='$photoname' where id_slider ='$row[0]' ";
$result3=mysql_db_query($dbname,$sql3);
}
unlink($fileupload);
}
Date :
2013-01-17 16:23:18
By :
konhuafu.it
มันอยู่คนละเงื่อนไขกันรึป่าวครับ ลองแบบนี้ว่าได้ป่าว
Code (PHP)
<?php
include"chkbrowser.php";
$name=$_POST[name];
$title=$_POST[title];
$fileupload=$_FILES['fileupload']['tmp_name'];
$fileupload_name=$_FILES['fileupload']['name'];
$fileupload_size=$_FILES['fileupload']['size'];
$fileupload_type=$_FILES['fileupload']['type'];
$sql="insert into slider values('','','$title')";
$result=mysql_db_query($dbname,$sql);
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" or $lastname=="png") {
$sql2="select max(id_slider) from slider ";
$result2=mysql_db_query($dbname,$sql2);
$row=mysql_fetch_row($result2);
$photoname=$name.".".$lastname;
copy($fileupload,"images/slideshow/".$photoname);
$sql3="update slider set name_slider='$photoname' where id_slider ='$row[0]' ";
$result3=mysql_db_query($dbname,$sql3);
if ($result&$result3) {
echo "<script>alert(' Upload Finish ');</script>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0.1;URL=admin_slider.php\">"; exit();
} else {
$sql4="select max(id_slider) from slider ";
$result4=mysql_db_query($dbname,$sql4);
$row2=mysql_fetch_row($result4);
$sql5="delete from slider where id_slider='$row2[0]' ";
$result5=mysql_db_query($dbname,$sql5);
echo "<script>alert(' Error Picture over 512 K. ');</script>";
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0.1;URL=admin_slider.php\">"; exit();
}
}
unlink($fileupload);
}
mysql_close();
?>
Date :
2013-01-17 17:38:09
By :
arm8957
ขอบคุณนะครับคุณ คนธรรมดา ไม่พิเศษ ผมลองแล้วไม่ได้ครับ
Date :
2013-01-17 19:01:14
By :
konhuafu.it
Load balance : Server 01