PDA

View Full Version : File Upload Field IE , Safari , Opera fileInput error.



mert.yilmaz
19 Apr 2012, 5:12 AM
Hello, we have an error about fileInput for these browsers : IE, Safari, Opera . we are getting file size when user select for import files with the code;


Ext.getCmp("filetouploadfield").fileInput.dom.files.length

this code is working in chrome and ff 3.6.

We debugged on IE developer kit and Ext.getCmp("filetouploadfield").fileInput.dom.files is undefined.

We tried post and get method:


if (fp.getForm().isValid()) {
fp.getForm().submit({
url: 'Default.aspx',
waitMsg: 'Uploading your file...',
success: function (fp, o) {
msg('Success', 'Processed file "' + o.result.file + '" on the server');
}
// failure: function (fp, o) {
// msg('failure');
// }





and we get an error about json decode.

How we can get the file and file size in IE 9 or HTML 5

scottmartin
19 Apr 2012, 10:11 AM
I believe you will have to use an ActiveX control or SWFUpload to perform this correctly



function getSize()
{
var myFSO = new ActiveXObject("Scripting.FileSystemObject");
var filepath = document.upload.file.value;
var thefile = myFSO.getFile(filepath);
var size = thefile.size;
alert(size + " bytes");
}


The other option is to use your backend to validate the filesize.

Regards,
Scott.

mert.yilmaz
19 Apr 2012, 10:17 PM
Thank you for your advice. But we must try GET POST methods.