is there a way to get all the uploaded file names as an array?

Sep 16, 2008 at 6:46 AM
hi flajaxian,

1st up, can i say - the upload is excellent, one of the best components i've used for ages.

is there a way to get all the uploaded file names as an array?

for example on my insert pages, i currently submit the form, add the record, do the upload and then create a folder inside my uploads folder named with the id of the row just created. i then move all the images that have just been uploaded into this folder.

i've been scratching my head with 'FileReceived' but i *think* this deals with when a file actually gets to the server and at that point (with an insert page) i wont know the row id yet...

any pointers would be great!

cheers,

jake
Coordinator
Sep 16, 2008 at 3:25 PM
Edited Sep 16, 2008 at 3:26 PM

Hi Jake Williamson,

The upload is done with each file having it's own request. But what you want can be done with client side code using the latest addition to the control as:
<script language="JavaScript">
    window._file_array = null;
    function fileUploaded(obj){

        if(obj.index == 0) window._file_array = [];

        window._file_array.push(obj.name);
       // you can use also obj.size, obj.status (Uploaded = 3,Error = 5)

        if(obj.isLast){
          document.location.href =
                "SubmitAllFiles.aspx?files="+window._file_array.join(":");
          // or even better create Ajax request here to send the list of files to the server
        }
    }
</script>

        <fjx:FileUploader ID="FileUploader1" 
                                FileUploadedJsFunc="fileUploaded" runat="server" >
...
        </fjx:FileUploader>

Sep 17, 2008 at 12:22 AM
hi flajaxian,

brilliant, i *think* that solves what i'm after ;)

the only thing i may change is to pass the array to a hidden field in a comma deliminated list. that way i can loop through when i submit the form and add each of the image details to the database once i have the row id to relate to.

i'll post up the solution once i've got it working, will be interesting to see the feedback.

cheers,

jake