HZGN.COM
welcome to my space
X
Search:  
Welcome to:hzgn.com
 HOME   [Solved] File upload from Form with other fields
[Solved] File upload from Form with other fields
Published by: cfz 2009-01-07
  • Handling Form-based File Upload with Java Servlet or JSP ::
    For other versions of Commons FileUpload, the procedures may be slightly different . Retrieving Values of Ordinary Form Fields with Java Servlet / JSP
    http://blog.csdn.net/Aragorn_177/archive/2008/12/01/3420296.aspx
    HOME
    There seems to be alot of posts on file upload issues, but none of the ones I looked through actually discuss how this works but it must be common.

    I have a form that has an inputType: 'file' TextField on it, along with a few other normal fields. This form is for uploading a file and linking that file to a record in a database, so the details of the upload are also stored in a table.

    After playing with it for a bit, it looks like I can either have a File Upload that doesn't send the other field values, or a normal HTTPRequest that sends the data but no file (I'm aware of why you can't send a file over HTTPRequest)

    Here is a snippet of the form:

    // Initiate the form including the action url when submitted
    thisForm = new Ext.form.Form({
    labelWidth: 80,
    url: '../../ajax/upload/upload-scriptinst-file.php',
    buttonAlign: 'left',
    fileUpload: true
    });

    // Setup all of the fields onthe form
    var scriptFile = new Ext.form.TextField({
    fieldLabel: 'File',
    name: 'scriptFile',
    width: 200,
    allowBlank: false,
    inputType:'file'
    });

    var name = new Ext.form.TextField({
    fieldLabel: 'Name',
    name: 'name',
    width: 200,
    allowBlank: false
    });

    // Add the fileds to the form (using a fieldset)
    thisForm.add(
    scriptFile,
    name
    );

    // Add the save button that submits the form
    File upload - MultiPowUpload – file upload component ActiveX/Java ::
    With file Uploader, the mode to upload files via HTML input fields will be to the specification that is defined in RFC 1867 (Form-based File Upload).
    http://file-upload.safe-install.com/
    HOME
    AJAX forms and file uploading in Rails « RailsBlaster::
    Sep 20, 2007 The best link I could find for Rails AJAX file uploading was Dave client filesystem (for security reasons), and thus, file form fields.
    http://railsblaster.wordpress.com/2007/09/20/ajax-forms-and-file-uploading-in-rails/
    HOME
    thisForm.addButton('Upload File', function(){
    if (thisForm.isValid()) {
    thisForm.submit({
    waitMsg: 'Saving...',
    failure: function(thisForm, action) {
    // Fail Stuff
    },
    success: function(thisForm, action) {
    // Success Stuff
    }
    ASP huge file upload free download Easy to use, hi-performance ASP ::
    Fill out PDF forms and other electronic forms (DOC, XLS… All Converter 6.0.2 . Free Download now Free Download ASP huge file upload 2.1 from motobit.com
    http://3d2f.com/programs/0-252-asp-huge-file-upload-download.shtml
    HOME
    Working with Form 'file field' data in ASP.::
    4 posts - Last post: Jun 24, 2006It does not work for file upload fields. It works for all other form fields, but not for file upload fields. The solution:
    http://webforumz.com/classic-asp/6996-working-with-form-file-field-data.htm
    HOME
    });
    }else{
    // Form ain't valid stuff
    }
    }, thisForm);

    // Render the form
    thisForm.render('files-upload-form');


    My questions are:

    1. How do I send data from the other fields using the fileUpload:true option. The only thing I can think of is adding a param: {} set under the form submit and accessing the form items

    2. How do I get a response from the server this way? I read in another thread that this method can only return XML or HTML, not JSON. But then I see another poster here say that they successfully pass JSON back to client. As you can see, the server-side script will save a file to the file system, and insert records in a database. I need to add error reporting for both actions so the user can see the reason for failure.


  • Of course you could always use a managed iframe panel to submit into using a standard form post...


  • I haven't tested it personally but reading the source tells me that other fields should be normally submitted with the form.

    BTW, you create your form as new Ext.form.Form. Are you using Ext 1.x version? (I've read 2.0 sources...)


  • Hi Saki,

    After testing that, you are correct. Just flying blind on Firebug is all.

    And I even tried returning JSON Responses despite what I read earlier and it works!

    With the code in my first post, here is the code on my PHP page that does the work:


    $name = $_REQUEST['name'];
    $target_path = ($_FILES['scriptFile']['name']);

    if(!move_uploaded_file($_FILES['scriptFile']['tmp_name'], $target_path)) {
    die('{"success":false, "errors":[{"errorText":"There was an error uploading the file"}]}');
    }

    /* Database work with the other variables goes here */


    Thanks again Saki.





  • Red Hat's Rough Recovery From CFO Exit
    Windows Live Finds a New, Pre-installed Home
    You are looking at:hzgn.com's [Solved] File upload from Form with other fields, click hzgn.com to home
    #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about [Solved] File upload from Form with other fields , Please add it free.
  • question for medical transcriptionists
  • how do i write this address
  • the ignorance is driving me crazy
  • question for people who live in small new england towns
  • trying to find out about gays please help
  • can anyone tell me what the general rule is for appearing in the local paper after being charged or in court
  • do you believe it 039 s possible to make someone fall in love with you
  • shakespeare sonnet 116
  • what is your favorite book from every genre
  • what is your definition of a 039 spoiled 039 person
  • what kind of songs do agers like
  • i don 039 t understand no matter what people have ish to say i hate double standards on women what 039 s the deal
  • what is the basic knowledge one must know to become a nurse assistant
  • how many people die in one year from illegal drugs in america
  • phone help urgent 10 points to best answer
  • if the officer is in a private driveway clocking people 039 s speed is that legal
  • what do u think of this pair of havaianas flip flops for a guy
  • any good fanfics out there
  • just how hard is it to live on your own when you first move out of your parents 039 house
  • sonnet 116 please help
  • stupid question for guys and girls
  • date rape definition and alcohol college
  • t v prison break where has it gone
  • i was out late last night when i happened on a friendly cat
  • is it okay to be different
  • can my attacker be deported
  • identifying a career in health and fitness
  • About us |Contact us |Advertisement |Site map |Exchange links
    Copyright© 2008hzgn.com All Rights Reserved