|
 |
|
ขอความกรุณาดู code ให้หน่อยน๊า ไม่รู้ว่าต้องไปแก้ตรงไหนนะ |
|
 |
|
|
 |
 |
|
Code (PHP)
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
if ($_FILES["pname"]["name"]!=NULL){ //บรรทัดนี้แระ
foreach ($_FILES["pname"]["tmp_name"] as $key => $tmpfile){
$insertSQL = sprintf("INSERT INTO pic (pname, ptitle) VALUES (%s, %s)",
GetSQLValueString($_FILES["pname"]["name"][$key], "text"),
GetSQLValueString($_POST['ptitle'], "text"));
mysql_select_db($database_Melody, $Melody);
$Result1 = mysql_query($insertSQL, $Melody) or die(mysql_error());
move_uploaded_file($tmpfile,"../gallery/images/".$_FILES["pname"]["name"][$key]);
}
}
}
จะทำเกี่ยวกับการอัพโหลดรูปนะ แต่ว่ามีปัญหาตรงที่ ถ้า เราไม่ได้ส่งค่ามา ก็ตั้งให้เช็คเป็น NULL แต่แล้ว มีปัญหาตรงที่ สมมุติเรามีให้ส่งไฟล์มา หกตัว แล้วมี ช่องใด ช่องหนึ่งไม่ได้ส่งค่ามา มันไม่ยอมรับค่าทุกตัวเลยอะ T-T
Code (PHP)
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1" enctype="multipart/form-data">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right"><pre>รูปภาพ</pre></td>
<td><pre> : <input type="file" name="pname[]" value="" size="32" /></pre></td>
<td><pre> : <input type="file" name="pname[]" value="" size="32" /></pre></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"></td>
<td><pre> : <input type="file" name="pname[]" value="" size="32" /></pre></td>
<td><pre> : <input type="file" name="pname[]" value="" size="32" /></pre></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"></td>
<td><pre> : <input type="file" name="pname[]" value="" size="32" /></pre></td>
<td><pre> : <input type="file" name="pname[]" value="" size="32" /></pre></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"></td>
<td><pre> <input type="submit" value="เพิ่ม" /></pre></td>
</tr>
</table>
<input type="hidden" name="ptitle" value="<?php echo $row_cpGallery['title']; ?>" />
<input type="hidden" name="MM_insert" value="form1" />
</form>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2011-06-29 12:35:07 |
By :
MermaidMelody |
View :
699 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง print_r ($_FILES); แล้วดูว่ามีค่าอะไรส่งมาบ้างครับ
|
 |
 |
 |
 |
Date :
2011-06-29 12:50:24 |
By :
oxygenyoyo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใจจร้า ไล่ได้แร้ว อิๆ
|
 |
 |
 |
 |
Date :
2011-06-29 13:37:13 |
By :
MermaidMelody |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|