jquery ไม่ส่งค่า <input type="file"> คืนกลับมาคร

แต่ถ้าเป็น <input type="text"> มันจะส่งค่ากลับได้ โค้ดตามนี้ครับ

ไฟล์ html


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">


<head>


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<title>Untitled Document</title>


<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>


<script type="text/javascript">


function check(){


var sel=document.getElementById('form'); //สำหรับให้ firefox อ่านค่าได้


$.post('data.php',{ name: sel.picture.value },


function (output){


$('#show_alert').html(output).show();


});


}


</script>


</head>


<body>


<form name="sel" id="form" method="post">


<input name="picture" type="file"/>


<input type="button" name="chk" onClick="check();">


<div id="show_alert"></div>


 </form>


</body>


</html>



//ไฟล์ data.php

<?php

echo $_FILES['picture']['name'];//ไม่ return ค่ากลับแต่ถ้าเป็น echo $_POST['picture']; สามารถส่งค่ากลับได้ครับ

?>

14 ก.ย. 2554 3 2,722

รบกวนช่วยดูหน่อยครับ ว่ามันเป็นเพราะอะไร มีวิธีแก้ไหมครับ
#1

อ้างอิงจาก ความคิดเห็น #1รบกวนช่วยดูหน่อยครับ ว่ามันเป็นเพราะอะไร มีวิธีแก้ไหมครับ


555+++



ปกติครับ โดยปกติ Ajax ไม่รองรับการส่งไฟล์ครับ อาจต้องใช้เทคนิคอื่นเพิ่มเติม ครับ

#2

ขอบคุณครับ ผมเพิ่งรู้นะเนี่ย
#3
ความคิดเห็น
ไฟล์อัปโหลด ชนิด jpg, jpeg ขนาดไฟล์ไม่เกิน 1024
^