I have a form
<form id="profile_imageform" class="image_form" enctype="multipart/form-data">
<fieldset>
<div class="entry">
<label>Filename:</label>
<input type="file" name="file" id="file" />
</div>
</fieldset>
<div class="actions">
<button type="submit">Save & Close</button>( <a href="#/profile" class="cancel">Cancel</a> )
</div>
</form>
and my js file look like
ProfileForm.prototype.init = function(){ var self = this;
//Initialize properties
this.view = $( "#profile_form_view" );
this.imageForm = $( "#profile_imageform" );
this.fields.id = this.imageForm.find( ":input[ name = 'id' ]" );
this.fields.image = this.imageForm.find( ":input[ name = 'file' ]" );
//Bind the submit handler
this.imageForm.submit(function( event ){
//Submit the form
self.saveImage(this.fields.id.val(), this.fields.image.val());
//Cancel default event
return( false );
});
ProfileForm.prototype.saveImage = function( id, image, onSuccess, onError ){
var self = this;
application.ajax({
url: "test.php",
data: {
method: "saveImage",
id: id,
image: image
},
success: function( response ){
if (response.success){
onSuccess( response.data );
}else{
onError( response.errors );
}
}
});
};
but
this.fields.image.val()
returns the image name what i need is it's tmp_name. Will it possible to get it's tmp_name at jQuery? If so how?
But this php code also returns error
if (isset($_POST['method']))
{
if (isset($_POST['image']))
{
echo $_FILES['image']['tmp_name'];
}
}