i have a form that has an input field that takes in a file, im trying to get the input of a file, lets say an image. after this i then use php to then check the file type and upload it to a database. how can i get jquery to post the image file to php so that php can perform its function. i can get the attr of other fields but not the image.
html
<input type="file" name="upload" id="upload"/>
jquery
//how do get the file
var img = //left blank what should i get
var a = 'form1';
var url = "upload_data.php";
$.post(url, {a:a, file:img, other:fields}){
//success
}
php
$p = $_POST['a'];
$file = $_POST['file'];
$iname = $_FILES['file']['name'];
$isize= $_FILES['file']['size'];
$itemp= $_FILES['file']['tmp_name'];
$otherfield = $_POST['other'];
if($p = 'form1'){
form1func($otherfield, $file, $iname, $itemp); // at this point will this work since i used jquery if wont what is the best solution at this point.
}
may not be clean but i hope someone gets the idea
post. You'll have to either use flash, or do it from within aniframe. There are many libraries out there that can do this for you. Here's one: valums.com/ajax-upload