0
我需要幫助來傳遞:從HTML表單傳遞變量JS把PHP的
<input type="file" id="upload"/>
到腳本,它傳遞給PHP頁面JS。 PHP頁面中我需要有這樣的代碼上傳的文件,但我將無法獲取這些變量:
move_uploaded_file($_FILES['uploadfile']["tmp_name"],$_FILES['uploadfile']["name"]);
在js腳本我使用Ajax jQuery函數給出,用POST方法的價值html對象。
JS代碼:
uploader = document.getElementById('uploader');
dati1="allegato="+uploader;
$.ajax({
type: 'POST',
url: 'ineriscinew.php',
data: dati1,
success: function(msg){ alert(msg); }
});
但是採用這種代碼,我將無法獲取的PHP變量:$ _FILES [ 'uploadfile'] [ 「名稱」]
我希望你能幫助我。 謝謝。
什麼是document.getElementById('uploader')引用在您的HTML? – steve