Merry Christmas

I need to do an AJAX form submission for a basic image table. I'm
following the strategy described here:
http://web2py.com/books/default/chapter/29/11#Ajax-form-submission

whereby I create an HTML form by hand, and have a SQLForm handle the
submission. The record gets inserted fine, except that the image I
choose is not being uploaded, but a .txt file shows up in the uploads
folder instead.

Is it possible to use web2py's upload functionality with AJAX
submissions? What are my options here?

(NOTE: I need to use native jQuery ajax, not web2py ajax helpers, due
to extenuating circumstances)

The form:

<form id="image-form">
<input id="image_title" id="image_title" name="title" type="text"
value="">
<input id="image_file" name="file" type="file" />
<input type="submit" name="Submit"/>
</form>

<script>


$(function() {

        $('#image-form').submit(function() {

                        $.update('{{=URL(c='images', f='process')}}', {
                                title: $('#image_title').val(),
                                file: $('#image_file').val(),
                                });
                        return false;
        });
});
</script>

Reply via email to