PHP Upload with an Ajax call |
[eluser]Unknown[/eluser]
I'm trying to upload files using an Ajax call; I've been searching the webs for the last few days and found some plugins; however, is it possible to use my current function: it works as a standalone function to be called; but I can't get it to be called via JS. Thanks. Code: function changeBookPicture($table, $bookId) This is how I want to call the upload function: Code: $("#upload-button").click(function(e){
[eluser]cloude[/eluser]
that would depend on how you make the ajax call i guess. http://jquery.malsup.com/form/ might work never used it myself
[eluser]Unknown[/eluser]
I doubt that would work. I can grab that portion of the view with another ajax call to refresh the picture; however, i want to be able to upload the image with an ajax that calls the changeBookImage function. I can manage after the upload has been successful.
[eluser]Rok Biderman[/eluser]
You actually shouldn't have any problems calling a CI method inside a post request. Anything like this should work: Code: $.post('<?php echo site_url('contoller/method'); ?>', { The main problem with what you're trying to do is that Javascript has no access to local files (security issues), so there is no way you can make it solely as an AJAX post request. It has to be done inside a iframe, like all the other "ajax" upload solutions out there. I've posted an example of Codeigniter/Uploadify integration for another user just a few days ago. Take a look at it and see if you can use it.
[eluser]Aken[/eluser]
The new FormData Javascript class makes uploading via ajax super easy. It just isn't supported by all browsers (specifically Internet Explorer). http://stackoverflow.com/questions/53923...query-ajax
[eluser]Ajaxboy[/eluser]
If it helps Cjax has two built in plugins that can upload files through flash + jquery and other without jquery: http://cjax.sourceforge.net/examples/plu...oadify.php http://cjax.sourceforge.net/examples/plu..._files.php |
Welcome Guest, Not a member yet? Register Sign In |