0
我是一個業餘程序員。我編碼上傳並插入到數據庫的功能與PHP和jQuery的AJAX,但它不能正常工作 我的形式用php和jquery上傳並保存到數據庫ajax
<form>
<input type="file" id='iputfile1' />
</form>
我的jQuery腳本
iputfile1 = $("#iputfile1").val();
jQuery.ajax({
type:"POST",
url:"ex.php", //goi toi file ajax.php
data:"filename"=filename+"&+"&iputfile1="
+iputfile1,
success:function(html){
jQuery("#responseDiv").show();
jQuery("#responseDiv").html(html);
}
});
我ex.php文件
$iputfile1 = $_REQUEST['iputfile1'];
print_r($iputfile1)
選擇文件後,提交我的ex.php文件不recivice $ _file ['tmp']
你可以在JavaScript中使用'FormData'對象,並且注意上傳的文件在'$ _FILES'裏面,在這裏搜索,已經有很多關於通過jQuery上傳的文件的內容 – Ghost 2015-04-02 02:46:51