4 Replies Latest reply on Feb 26, 2008 1:49 PM by vEr5e

    More than one upload file at a time?

    vEr5e Level 1
      Say if I have like more than one file upload field in my form, is there a way where I can do the upload of all the files together just like what I usually do in HTML?

      I am having the problem to do this because apparently, PHP only receives the $_FILES['Filedata'], which is only one of the upload fields that I have on a form. So it only allows a single upload when a submit button of a form is clicked on.
        • 1. More than one upload file at a time?
          m_hartnett Level 3
          There are 2 types of objects in Flex for uploading files. The FileReference ( used to upload a single object) and the FileReferenceList object for uploading multiple objects. Take a look at the example of how the FileReferenceList accomplishes its task.

          It amounts to uploading one file at a time and utilizing the callback methods to begin the next upload. Your server object should only handle one file at a time.

          Go here and look at the FileReferenceList example
          http://livedocs.adobe.com/flex/201/langref/index.html
          • 2. Re: More than one upload file at a time?
            vEr5e Level 1
            Thanks mhartnett.

            I have looked at the example on the link you gave. According to the example for the FileReferenceList in the documentation, it seems to make multiple or rather separated requests to the server-side upload script.

            So for example if I have 3 files to upload, the script will call the the upload() function of the FileReference class thrice with the URLRequest(which is the server-side upload script). So in this case, my server-side script that is handling the upload will only upload one file at one time.

            Is there a way where I can have say all the 3 files sent together to the server-side script, and then have them uploaded all at once within the server-side script itself?

            So say my PHP file, I could have access to like $_FILES['Filedata1'], $_FILES['Filedata2'] and $_FILES['Filedata3'] together at one request.
            • 3. Re: More than one upload file at a time?
              m_hartnett Level 3
              Flex objects will only allow one file to be uploaded at a time. here is a quote from the Flex API for the upload method of the FileReference object.

              "Listeners receive events to indicate the progress, success, or failure of the upload. Although you can use the FileReferenceList object to let users select multiple files for upload, you must upload the files one by one; to do so, iterate through the FileReferenceList.fileList array of FileReference objects."

              So the answer is no. You need to upload each file one at a time.

              • 4. Re: More than one upload file at a time?
                vEr5e Level 1
                aww...Still, thanks mhartnett for that. :)