PDA

View Full Version : Change or add new files in FileField



fabio.policeno
31 Jan 2012, 2:58 AM
Hello,

I am developing a component for uploading multiple files, either by button or by drag drop to the browser. There are two options and would like to know how to make one:

- Assuming I upload 3 files with the button, my FileField (modified for multiple) is populated with these three files. Now I upload more files by drag drop 2, these two files, I have no idea how to send them, so I thought I'd add in FileField (to join with the 3 files previously sent by the button) in the field, the files are stored in: filefield.fileInputEl.dom.files, the problem that is not quite an array, because I could not push him to apply (filefield.fileInputEl.dom.files.push(newFileDragDrop) does not work), any idea add new files in FileField?

- Another option would be to do a post every file added, either by button or by drag drop for that, I tried to manually change, eliminating the file sent from FileField and adding a new, as a setValue after each uploaded file , populating the field with a new file (filefield.fileInputEl.dom.files[0] = newFile did not alter the contents of FileField), but neither abtive success. Any way to change the content (file) of the FileField?

Thank you!

mitchellsimoens
31 Jan 2012, 7:55 AM
For file drop you won't be able to use a File field. You will need to do your own XMLHttpRequest

fabio.policeno
31 Jan 2012, 8:29 AM
File transfer via XMLHttpRequest? How?

mitchellsimoens
31 Jan 2012, 8:35 AM
File transfer via XMLHttpRequest? How?

Here is an example I wrote a couple years ago (hasn't been updated and was written very fast). It uses Ext JS 3 but the actual drop/upload source should still work. This was using FF

fabio.policeno
31 Jan 2012, 10:20 AM
I go view this. Thank's!

fabio.policeno
31 Jan 2012, 11:14 AM
thisFile.file.getAsBinary is not a function


chrome://firebug/content/blank.gif

req.sendAsBinary(thisFile.file.getAsBinary());



FF 10 and Ext JS 3.3.1

fabio.policeno
1 Feb 2012, 3:45 AM
Ported the Ext.ux.XHRUpload (http://code.google.com/p/awesomeuploader/source/browse/branches/beta/Ext.ux.XHRUpload.js?r=4) to version 4.

Thank you!