Good point. Maybe submit an issue<http://code.google.com/p/web2py/issues/list>and reference this thread.
Anthony On Tuesday, October 30, 2012 11:03:35 AM UTC-4, captainy wrote: > > Hey Anthony, > > i've tried this recipe and it works. In my opinion it's a common task in > modern web development to upload files in the "ajax-way". My problem is, as > with as other recipes in the book, the modification of a core file of the > web2py framework. What happens, if we do an update to a newer version of > web2py? I think all this modifications will be lost. What do you think is > the best way to handle this problem? > > Regards, Paul > > Am Dienstag, 7. August 2012 06:43:36 UTC+2 schrieb Anthony: >> >> At the end of this >> section<http://web2py.com/books/default/chapter/29/12#Components>in the book >> it says: >> >> *Please note:* Because Ajax post does not support multipart forms, i.e. >>> file uploads, upload fields will not work with the LOAD component. You >>> could be fooled into thinking it would work because upload fields will >>> function normally if POST is done from the individual component's .load >>> view. Instead, uploads are done with ajax-compatible 3rd-party widgets and >>> web2py manual upload store commands. >> >> >> In the web2py >> cookbook<http://www.packtpub.com/web2py-application-development-recipes-to-master-python-web-framework-cookbook/book>, >> >> there is a recipe for this. The app associated with that recipe can be >> downloaded here: >> https://github.com/mdipierro/web2py-recipes-source/blob/master/apps/04_advanced_forms/web2py.app.upload.w2p. >> >> It uses the jquery.form.js plugin: >> http://jquery.malsup.com/form/#file-upload. The app includes a >> customized web2py_ajax.js (which is named web2py.js in more recent versions >> of web2py) with a custom version of web2py_trap_form(): >> >> function web2py_trap_form(action,target) { >> jQuery('#'+target+' form').each(function(i){ >> var form=jQuery(this); >> if(!form.hasClass('no_trap')) >> if(form.find('.upload').length>0) { >> form.ajaxForm({ >> url: action, >> success: function(data, statusText, xhr) { >> jQuery('#'+target).html(xhr.responseText); >> web2py_trap_form(action,target); >> web2py_ajax_init(); >> } >> }); >> } else { >> form.submit(function(e){ >> jQuery('.flash').hide().html(''); >> web2py_ajax_page('post',action,form.serialize(),target); >> e.preventDefault(); >> }); >> } >> }); >> } >> >> Anthony >> >> On Monday, August 6, 2012 11:49:27 PM UTC-4, Picheth wrote: >>> >>> I have a problem with the upload file using the LOAD (....., ajax = True) >>> >>> >>> please .. any help, cues or snippets of codes to accomplish this ... >>> will be greatly appreciated >>> >>> Picheth. >>> >> --

