PDA

View Full Version : How can I get the informations of the selection of a filefield ?



Elfayer
1 Oct 2012, 4:36 AM
Hi,
I have a filefield with a multiple selection, but I can't find informations like how many files have been selected, the MIME type, the size, etc...

Here is the code :


{
xtype: 'filefield',
itemId: 'browseButton',
buttonOnly: true
}


uploadWin.down('#browseButton').fileInputEl.dom.setAttribute('multiple', '1');

Elfayer
2 Oct 2012, 4:57 AM
The problem persist, I can't get any information of the selection. Not even the name or the number of selected files.

scottmartin
2 Oct 2012, 9:26 AM
The filefield does not return anything when using getValues(), so you could using something like:



form.getForm().getFields().items[0].value // assuming 1st item is filefield


So to check form (getFields()), just cycle fields, or you can use ComponentQuery() to only check filefield

Scott.

Elfayer
2 Oct 2012, 11:14 PM
With that line, I only get the name of the file, but I'd like to upload this files and I don't think it's possible with only that.

evant
2 Oct 2012, 11:22 PM
The short answer is you can't, at least not in a cross browser way. Newer browsers support the Files API: http://www.html5rocks.com/en/tutorials/file/dndfiles/

Elfayer
3 Oct 2012, 12:26 AM
Thanks that link seems very interresting !

But I'd like again a thing: Can I upload with this informations?39101
I've succeed on getting that informations and before going further, I'd like to know if this informations are sufficient.

Elfayer
3 Oct 2012, 3:38 AM
I have an upload method in C# side that work. Is it possible with the informations I showed in the last post to fill a filefield? And how to do that?
Because in the C# side I make a Request of a filefield and then all the method work. But if I don't use a filefield to catch the informations in C#, I don't know how I can get an HttpPostedFileBase type, wich is the type I use for my upload.

Elfayer
11 Oct 2012, 11:47 PM
The short answer is you can't, at least not in a cross browser way. Newer browsers support the Files API: http://www.html5rocks.com/en/tutorials/file/dndfiles/

Do you know where can I find a browse button that work in all browser? Because this tuto doesn't work for IE.