|
 |
|
*** Random แล้วตั้งเป็นชื่อไฟล์ที่ upload แบบไหนครับ *** |
|
 |
|
|
 |
 |
|
date("YmdHis"); ใช้วันเวลาครับ เอาไปปรับใช้กับตัว upload
|
 |
 |
 |
 |
Date :
2009-09-28 00:07:27 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
while (true){
$prefix = rand(100000000, 999999999);
$file_ext = '.jpg';
$file_name = $prefix.$file_ext;
if(ชื่อไม่ซ้ำ) break;
}
if (move_uploaded_file($file['file_upload']['tmp_name'], $file_name)) {
//บันทึกลงฐานข้อมูล
}
|
 |
 |
 |
 |
Date :
2009-09-28 00:12:24 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
จู้ฮุกกรู้ ยังไม่นอนกันเหรอครับ ขอบคุณสำหรับแนวคิดครับ
|
 |
 |
 |
 |
Date :
2009-09-28 00:48:16 |
By :
chuensanguan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมงงตรงที่ตั้งชื่อใหม่นี่แหละครับ เพราะว่า upload เข้ามานี้จะเป็น $_FILES["file_upload"]["name"] ใช่ไหมครับแล้วคราวนี้ผมจะเปลี่ยนชื่อไฟล์ที่อัพโหลดเข้ามายังไงอ่ะ ยังงงอยู่
|
 |
 |
 |
 |
Date :
2009-09-28 10:46:19 |
By :
chuensanguan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
copy($_FILES["file_upload"]["tmp_name"],date("YmdHis").".jpg");
|
 |
 |
 |
 |
Date :
2009-09-28 10:56:35 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณคร้าบ ได้แล้วครับ อีกอย่างผมอยากได้เว็บที่ บอกชนิดไฟล์ทุกชนิดเลยคับ เช่น image/pjpeg , application/pdf ไม่ทราบมีเว็บไหมครับ
|
 |
 |
 |
 |
Date :
2009-09-28 11:17:53 |
By :
chuensanguan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมได้แล้วครับ file extension
http://www.mimetype.org/
เผื่อไว้ให้คนอื่นด้วยครับ
เครดิต คุณเอี่ยว
|
 |
 |
 |
 |
Date :
2009-09-28 12:44:06 |
By :
chuensanguan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|