Need help extending AjaxFileUpload Plugin with JQuery

Discussion in 'Javascript' started by Big Moxy, Dec 22, 2007.

  1. Big Moxy

    Big Moxy Guest

    This plugin can be downloaded from
    I want to add 2 fields to the sample form but do not know how. The
    variable s.fileElementId in the function ajaxFileUpload below is the
    name of the file to be uploaded. I can see where it is added to the
    form in the createUploadForm.

    Can someone please show me how to add 2 fields to this form so that I
    can use it in the php script called by the form action method?

    Thank you!!

    createUploadForm: function(id, fileElementId)
    //create form
    var formId = 'jUploadForm' + id;
    var fileId = 'jUploadFile' + id;
    var form = $('<form action="" method="POST" name="' + formId + '"
    id="' + formId + '" enctype="multipart/form-data"></form>');
    var oldElement = $('#' + fileElementId);
    var newElement = $(oldElement).clone();
    $(oldElement).attr('id', fileId);
    //set attributes
    $(form).css('position', 'absolute');
    $(form).css('top', '-1200px');
    $(form).css('left', '-1200px');
    return form;

    ajaxFileUpload: function(s) {
    // TODO introduce global settings, allowing the client to
    modify them for all requests, not only timeout
    s = jQuery.extend({}, jQuery.ajaxSettings, s);
    var id = new Date().getTime()
    var form = jQuery.createUploadForm(id, s.fileElementId);
    var io = jQuery.createUploadIframe(id, s.secureuri);
    Big Moxy, Dec 22, 2007
    1. Advertisements

  2. [snip regarding jQuery plugin]

    Most of the regular contributors to comp.lang.javascript recommend
    against using big general purpose libraries like jQuery and Prototype.
    If you search the group archives you will see many posts that question
    the quality of the code. However if you are locked in then questions
    specific to jQuery will likely receive better answers from the jQuery

    Peter Michaux, Dec 22, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.