|
|
|
โค้ดนี้ดักไม่ให้มันเข้า state ตรงไหนดีครับ เช็คนามสกุลไฟล์ได้แล้ว แต่มันก็แอดเข้าฐานข้อมูลอยู่ดี |
|
|
|
|
|
|
|
โค้ดนี้ดักไม่ให้มันเข้า state ตรงไหนดีครับ เช็คนามสกุลไฟล์ได้แล้ว แต่มันก็แอดเข้าฐานข้อมูลอยู่ดี
Code (PHP)
if($_FILES["g_pic"]["name"]!="")
{
$ext = strtolower(end(explode('.', $_FILES["g_pic"]["name"])));
if(strchr($g_pic_name,".")==".JPG" ||
strchr($g_pic_name,".")==".jpg" ||
strchr($g_pic_name,".")==".JPEG" ||
strchr($g_pic_name,".")==".jpeg" ||
strchr($g_pic_name,".")==".GIF" ||
strchr($g_pic_name,".")==".gif"||
strchr($g_pic_name,".")==".PNG" ||
strchr($g_pic_name,".")==".png"
)
{
$ints = date('YmdGis');$ext="";$ext1="";
$ext=substr($_FILES["g_pic"]["name"],strpos($_FILES["g_pic"]["name"],"."));
$img=$idalbum."gstu".$ints.$ext;
copy($_FILES["g_pic"]["tmp_name"],$_SERVER['DOCUMENT_ROOT']."/images/gstudent/$img") or die ("The file couldn't be copied to the server");
$up_img=",g_pic='$img'";
echo "Upload to Folder images/gstudent";
} else{
echo "Please upload only file type Gif, Jpg, Png";
}
if($_POST["state"]=="add") {
$sql="INSERT INTO gstudent(g_name,g_detail,g_etc,g_pic,g_date) VALUES('".$_REQUEST["g_name"]."','".$_REQUEST["g_detail"]."','".$_REQUEST["g_etc"]."','$img',NOW())";
$db->execCommand($sql);
echo "<script type=\"text/javascript\">alert(\"กรอกข้อมูลเรียบร้อยแล้ว\");history.back();</script>";
Tag : PHP
|
|
|
|
|
|
Date :
2012-06-20 16:51:21 |
By :
l3alLkisS |
View :
957 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองดู
Code (PHP)
<?php
if($_FILES["g_pic"]["name"]!="")
{
$ext = strtolower(end(explode('.', $_FILES["g_pic"]["name"])));
if(strchr($g_pic_name,".")==".JPG" ||
strchr($g_pic_name,".")==".jpg" ||
strchr($g_pic_name,".")==".JPEG" ||
strchr($g_pic_name,".")==".jpeg" ||
strchr($g_pic_name,".")==".GIF" ||
strchr($g_pic_name,".")==".gif"||
strchr($g_pic_name,".")==".PNG" ||
strchr($g_pic_name,".")==".png"
)
{
$ints = date('YmdGis');$ext="";$ext1="";
$ext=substr($_FILES["g_pic"]["name"],strpos($_FILES["g_pic"]["name"],"."));
$img=$idalbum."gstu".$ints.$ext;
copy($_FILES["g_pic"]["tmp_name"],$_SERVER['DOCUMENT_ROOT']."/images/gstudent/$img") or die ("The file couldn't be copied to the server");
$up_img=",g_pic='$img'";
echo "Upload to Folder images/gstudent";
$act = true;
} else{
echo "Please upload only file type Gif, Jpg, Png";
$act = false;
}
}else{
if(($_POST["state"]=="add")and($act)) {
$sql="INSERT INTO gstudent(g_name,g_detail,g_etc,g_pic,g_date) VALUES('".$_REQUEST["g_name"]."','".$_REQUEST["g_detail"]."','".$_REQUEST["g_etc"]."','$img',NOW())";
$db->execCommand($sql);
echo "<script type=\"text/javascript\">alert(\"กรอกข้อมูลเรียบร้อยแล้ว\");history.back();</script>";
}
}
?>
|
|
|
|
|
Date :
2012-06-20 17:51:06 |
By :
iamatomix |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|