0
我試圖通過ajax將文件發送到php腳本,但是我發現它沒有正確傳遞,因爲我試圖回顯該文件並得到了null
響應。我該如何解決這個問題?如何通過此ajax腳本獲取文件
HTML JS代碼
<script type="text/javascript">
$(function(){
$("#first").submit(function(event){
event.preventDefault();
$(this).find(".error").remove();
file = $(this).find("input[name=file_save]").val();
form = $(this);
url = $(this).attr("action");
$.post(url,{file_save:file}, function(data){
console.log(data);
},"json");
return false;
});
});
</script>
PHP腳本(addImages.php)
<?php
$username = $_POST['files'];
$tableau["error"] = $username;
echo json_encode($tableau);
?>
感謝的人,但我得到您所要求的變化,同樣的問題 – Bobby
@Bobby然後嘗試尋找到了[$ _FILES(HTTP:// php.net/manual/en/reserved.variables.files.php)變量。 – Ad5001