|
 |
|
ถึงคุณ Rastafari หรือคนอื่นๆที่เจอปัญหานี้ช่วยชี้แนะ |
|
 |
|
|
 |
 |
|
ลองทำตัวทดสอบดูก็ได้ครับ ว่ามันต่างกันยังไง ปรกติผมใช้ สกุลไฟล์เลย 
เอาค่าที่ได้ไปทำก็ได้คับ ลองอัพโหลดแล้วแสดง ไฟล์ไทป์ดูก็ได้คับ จะได้รู้ว่ามันต่างกันยังไง
ได้เรื่องยังไงก็เอามาโพสบอกต่อกันด้วยนะครับ
|
 |
 |
 |
 |
Date :
2009-10-01 17:55:12 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
http://compsci.ca/v3/viewtopic.php?t=16159
ดูเอาจากที่นี่ครับ ว่าต่างกันต่างไหน อิอิ
|
 |
 |
 |
 |
Date :
2009-10-01 17:57:55 |
By :
apicha31 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เดียวจะลองดูคับเพ่เอี่ยว
ตามที่เพ่ P@e ให้มานั้นผมลองดูแล้วเมื่อวาน มัน เพี๊ยนไปเลยทั้งที่เป็นไฟลืภาพนามสกุลที่กำหนดแท้ๆดันยัง alertออกมาต้องเป็นไฟล์ GIF,JPG เฉยเลย ถ้าเพ่Rastafari ลองทดสอบว่าใช้ได้แสดงว่า โค้ดผมมันเพี๊ยนเองแนะเลย ต้องเขียนหน้านี้ไหม่แล้วละซิ เดียวจะลองใหม่นะครับได้ผลหรือไม่ได้ยังไงเดียวมาบอกอีกทีครับ
|
 |
 |
 |
 |
Date :
2009-10-01 18:12:48 |
By :
somparn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เด่วๆๆ ผมแค่ทดสอบว่ามัน aler กับ FF ยังไม่ทดสอบละเอียด
ลองดูก่อนนะครับ
แล้วเด่วว่ากันอีกทีนะครับ
ยังประชุมไม่เสร็จเป็นห่วงเลยแวะมาดูเห้อๆๆ
|
 |
 |
 |
 |
Date :
2009-10-01 18:36:47 |
By :
pokultra |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โหเพ่ไม่ต้องรีบทำซะผมซึ้งน้ำใจเลย ผมทดสอบล่ะที่เครื่องผมนะ firefox และ IE มันบอกว่า ไฟล์ต้องเป็น JPG,GIF ทั้งที่เป็นนามสกุล JPG กับ GIF
ตัวนี้เลย
Code (PHP)
<script language="javascript">
function chk(){
var a=document.form1.image.value;
fty=new Array(".gif",".jpg",".jpeg",".png");
for(i=0;i<fty.length;i++){
if(a !="" && a.lastIndexOf(fty[i])==-1){
alert("อัพโหลดได้เฉพาะไฟล์ gif jpg jpeg png");
return false;
}
}
}
</script>
form ที่ทดสอบ
Code (PHP)
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1" onsubmit="return chk();">
<input name="image" id="image" type="file">
<input name="Submit" id="Submit" value="Upload" type="submit">
</form>
|
 |
 |
 |
 |
Date :
2009-10-01 18:51:58 |
By :
somparn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
"^image" อันนี้น่าจะเป็น regular expression หมายถึงตำแหน่งเริ่มต้นที่คำว่า image
if("^image",$_FILES['image']['type'])) คงหมายถึง ถ้าตำแหน่งต้น $_FILES['image']['type']ประกอบด้วยคำว่า image แปลว่าจริง
ความหมายคงประมาณ if(substr($_FILES['image']['type'],0,5) =="image")
แต่อันนี้ไม่รู้แห่ะจาวาสคริปเรียก reg แบบนี้ได้เหมือนกัน 
|
 |
 |
 |
 |
Date :
2009-10-02 01:05:21 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วเอามาชมกันบ้างนะครับ

|
 |
 |
 |
 |
Date :
2009-10-02 19:47:01 |
By :
pokultra |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แบบนี้คงไม่เวิร์ดมั้งครับ เพราะขึ้นต้นด้วย image นี่มีเพียบ
|
 |
 |
 |
 |
Date :
2009-10-02 22:55:22 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณ PlaKriM ชี้ทางสว่่างให้พวกเราทีครับ 
|
 |
 |
 |
 |
Date :
2009-10-03 08:45:07 |
By :
pokultra |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
บอกมาคับ ว่ามี MIME TYPE อะไรบ้างที่รับได้
|
 |
 |
 |
 |
Date :
2009-10-03 09:19:25 |
By :
pjgunner |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
".gif",".jpg",".jpeg",".png"
ประมาณนีี้อ่ะครับ
แล้วเด่วจะลองมาเพิ่มลดทีหลังอ่ะครับ
เพิ่มลดที่หลังได้ไหมครับ
|
 |
 |
 |
 |
Date :
2009-10-03 11:08:42 |
By :
pokultra |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$GLOBALS["mimetype"] = array("image/jpg" => ".jpg", "image/pjpeg" => ".jpg", "image/jpeg" => ".jpg", "image/gif" => ".gif", "image/png" => ".png");
function image_allowed($filetype){
return (array_key_exists($filetype, $GLOBALS["mimetype"])) ? true : false;
}
if(!image_allowed($_FILE['file']['type'])){
echo "กรุณาเลือกไฟล์นามสกุล " . strtoupper(implode(", ",array_unique($GLOBALS["mimetype"]))) . " เท่านั้นครับ";
}
|
 |
 |
 |
 |
Date :
2009-10-03 19:22:54 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โวๆๆ ได้ความรู้ใหม่จากเพ่ปลากริมอีกแล้ว 
|
 |
 |
 |
 |
Date :
2009-10-03 21:59:58 |
By :
somparn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณ คุณPlaKriM มากนะครับ
ส่วนคุณphpbasic คงได้นำไปใช้นะครับ
ผมขุดกระทู้นี้เพื่อคุณphpbasic และตัวผมด้วย อิอิ
*ปล. ขอเรียกทุกท่าน ว่า"คุณ" นะครับ เพราะไม่รู้อายุอานามกัน ไปเรียกพี่เดียวจะหาว่าไปว่าเขา แก่ อ่ะ
|
 |
 |
 |
 |
Date :
2009-10-05 13:47:15 |
By :
pokultra |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อ่อได้เรียบร้อยแล้วครับ แค่เพิ่ม jpeg เข้าไปอีกตัวเดียวเอง แต่ก็ได้ความรู้ใหม่จากเพ่ดุนยา กับเพ่ ปลากริมนั้นแหละ อายุนั้น 23 ครับแต่ความรู้นั้นไม่เยอะ เขียน php ได้เพราะว่าสนใจก็เลยศึกษาเองมาโดยตลอดก็เลยติดปัญหาบ้างครับ หุหุหุหุ
|
 |
 |
 |
 |
Date :
2009-10-05 13:55:05 |
By :
somparn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
   
|
 |
 |
 |
 |
Date :
2009-10-12 11:42:46 |
By :
apicha31 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|