|
 |
|
แปลงชื่อรูปแล้ว แต่คอลั่มที่ไม่มีรูป ก็ insert เลขรหัสที่แปลงลงไปเก็บด้วย ต้องเช็คเงื่อนไขยังไงดีครับ |
|
 |
|
|
 |
 |
|
Code (PHP)
$renamefcover= date("YmdHis")."_".$_FILES["book_fcover"]["name"];
$renamebcover= date("mYdHis")."_".$_FILES["book_bcover"]["name"];
copy($_FILES["book_fcover"]["tmp_name"],"myfile/".$renamefcover);
copy($_FILES["book_bcover"]["tmp_name"],"myfile/".$renamebcover);
//*** Insert Record ***//
include('.../include/config.inc.php');
$strSQL = "INSERT INTO book";
$strSQL .="(book_name,book_author,book_isbn,book_call,book_link,book_fcover,book_bcover,book_detail,book_lang,book_type,book_tag) VALUES
('".$_POST["book_name"]."',
'".$_POST["book_author"]."',
'".$_POST["book_isbn"]."',
'".$_POST["book_call"]."',
'".$_POST["book_link"]."',
'".$renamefcover."',
'".$renamebcover."',
'".$_POST["book_detail"]."',
'".$_POST["book_lang"]."',
'".$_POST["book_type"]."',
'".$_POST["book_tag"]."'
)";

ด้านบนแปลงไฟล์รูปได้ปกติ
ด้านล่างไม่ใส่รูปแต่ไฟล์ก็ยัง เก็บเลขที่แปลง
ทีเป็นแบบนี้เพราะ code ผมสั่งให้เก็บเลขรหัสที่แปลงไป ตอน insert ด้วย ผมจะเขียนเงื่อนไข ยังไงดีครับ
ถ้าไม่มีรูปเข้ามาจะไม่ แปลงชื่อไฟล์
ขอบคุณครับ
Tag : PHP

|
ประวัติการแก้ไข 2013-02-17 21:30:43
|
 |
 |
 |
 |
Date :
2013-02-17 21:30:25 |
By :
relatedlove |
View :
673 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วครับ
Code (PHP)
if($_FILES["book_fcover"]["name"]=="")
{
$renamefcover=$_FILES["book_fcover"]["name"];
}else
{
$renamefcover= date("YmdHis")."_".$_FILES["book_fcover"]["name"];
}
|
 |
 |
 |
 |
Date :
2013-02-17 21:34:55 |
By :
relatedlove |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|