Friday, December 18, 2009

Image POST with jquery

To post image to server we can not it directly like set variable name post it, that we do in $.ajax
for that you need to make iframe then make form tag so that the request contains the header with all file details like name,size,type etc.
Jquery make it simple by plug-in named 'ajax_postup' just download call to your page,
you can also find documentation download but i also write down here.

$.ajax_postup({url:'imagepost.php',//server url
file_ele_ids:['x_thumbnailimage'],//just give file name id
success:function(return_data)
{
//write down code for callback
}
});


The above code i think explain all things,
you can also pass other variable with code just write down before the 'file_ele_ids'
the syntax is data:{'var_name':'var_value', 'var_name':'var_value'},

On server side if you are using the PHP than you can access directly by
  1. $_FILE['filename_id']['name'] to access the file name same way
  2. $_FILE['filename_id']['type']
  3. $_FILE['filename_id']['size]
  4. $_FILE['filename_id']['tmp_name'] for server temp location file name.

Thanks
Have Dream Day

No comments:

Post a Comment