|
 |
|
ช่วยดูโค้ดให้ทีครับ อัพโหลดรูป ทำในเครื่องตัวเองไม่มีปัญหา แต่เวลาอัพขึ้นโฮสมันดันอัพรูปไม่ได้ครับ |
|
 |
|
|
 |
 |
|
ทำได้แล้วครับ
Quote:เครียดตั้งนาน ลืมคิดไปเลยว่าต้องเซ็ตโฟลเดอร์เก็บรูปให้เป็น 777 ซะก่อน เฮ้อ... ยิ่งรีบ ยิ่งมั่วจริงๆ เลย 
ผมใช้ iframe มาช่วยด้วยครับ
Code (PHP)
<form id="experimental_results" action='.$url[0].' name="frmMain" method="POST" enctype="multipart/form-data" target="iframe_target" >
<iframe id="iframe_target" name="iframe_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe>
ส่วนนี่โค้ดที่ใช้เช็คครับ
Code (PHP)
$extension = array('jpg','jpeg','png','gif','bmp'); // ประเภทไฟล์
$j = count($_FILES["image_solve"]["name"]);
for($i = 0; $i < $j; $i++)
{
$rand = substr(str_shuffle('ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789'),0,3); // สุ่มค่าในอาเรย์ แล้วตัดเอาเฉพาะตำแหน่ง 0-3
$ext = strtolower(pathinfo($_FILES["image_solve"]["name"][$i], PATHINFO_EXTENSION)); // คืนค่านามสกุลไฟล์ พร้อมเปลี่ยนตัวอักษรเป็นตัวเล็กทั้งหมด
if($_FILES["image_solve"]["name"][$i] != "" && in_array($ext,$extension)) // ตรวจสอบประเภทไฟล์ in_array(ค่าที่ต้องการให้ค้นหา, อาเรย์ที่ต้องการค้นหา
{
$sur = strrchr($_FILES['image_solve']['name'][$i], "."); // ตัดเอาเฉพาะนามสกุลไฟล์
$newfilename = ($i.$rand."_".Date("dmy_His").$sur); // ชื่อไฟล์ประกอบด้วย ( ลำดับ, ค่าที่สุ่มได้จาก $rand, วันเดือนปี_ชั่วโมง นาที วินาที ) .นามกุลรูป
/*-------------------------- เก็บรูปในโฟลเดอร์ --------------*/
if(move_uploaded_file($_FILES["image_solve"]["tmp_name"][$i],"img_results/".$newfilename))
{
($_POST["comment_image"][$i] != "")
?$insrt_img_details = "INSERT INTO image (id_image, id_zone, id_area, id_mostProblems, name_image, comment_image) VALUES ('NULL', '".$_SESSION["id"]."', '".$_POST["area"]."', '".$_POST["object_problem"]."', '".$newfilename."', '".$_POST["comment_image"][$i]."' ) "
:$insrt_img_details = "INSERT INTO image (id_image, id_zone, id_area, id_mostProblems, name_image) VALUES ('NULL', '".$_SESSION["id"]."', '".$_POST["area"]."', '".$_POST["object_problem"]."', '".$newfilename."') ";
$query_img_details = mysql_query($insrt_img_details) or die(mysql_error());
}
}
$count = 1;
ข้อมูลอย่างอื่นที่เป็นตัวอักษรก็อัพลงฐานข้อมูลได้หมด ไม่ได้แต่รูปครับ
งงมากเลย ทำไมเป็นแบบนี้ ช่วยดูให้ทีครับ เกิดจากอะไร dead line 2 วันสุดท้ายแล้วครับ T_T"
ขอบคุณครับ
Tag : PHP, MySQL, JavaScript, jQuery

|
ประวัติการแก้ไข 2012-06-11 21:26:00 2012-06-11 21:27:15 2012-06-11 21:36:12
|
 |
 |
 |
 |
Date :
2012-06-11 21:25:44 |
By :
fogza |
View :
1051 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 03
|