我想使用jquery上传文件而不使用submit。我试图用$ .post来做这件事,但我没有找到$ FILES [&#39; myfile&#39;] [&#39; name&#39;]和$ < / em> [&#39; myfile&#39;] [&#39; tmp_name&#39;]我需要php。这是我的代码。请帮忙。
<form method="post" enctype="multipart/form-data">
<input type='file' id='myfile' name='myfile' />
<input type='button' id='submit' value='Submit' onclick='new_data()' />
</form>
function new_data(){
action = 'new';
var file = $('#myfile').val();
$.post('upload.php',{action:action,file:file},function(data){('#post-values').html(data)});
}
<?php
if($_POST['action']=='new'){
echo $_FILES['file']['name'];
echo $_FILES['file']['tmp_name'];
}
?>