I want to upload files using jquery without using submit. I'm trying to do it wiht $.post but I'm not geting the $FILES['myfile']['name'] and $['myfile']['tmp_name'] that I need for php. Here are my codes. Please help.
<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'];
}
?>