PDA

View Full Version : Problems with fileupload field



varunjyoti
19 Mar 2012, 12:34 AM
Hi,

I am using Ext Js 4.0.5.
I have a simple file upload field.



xtype: 'filefield',
id: 'licenseFile',
emptyText: "Enter the server path of the License File. eg : C:\\dg\\Customer2311641139962.lic",
name: 'licenseFile'

There are 2 problems i am facing with it.
1) In IE8, the text on browse button is not displayed. The button is displayed but the text is not.
2) In IE9, when i select a file after pressing the "Browse" button, the text field shows the path like "c:/fakepath/abc.txt". In all the paths, "fakepath" is displayed in text field

chramer
19 Mar 2012, 4:05 AM
Maybe it's an Ext bug.. Try ExtJS 4.0.7..
http://jsfiddle.net/serju/F4YxN/1/ - I checked and this works in all browsers (ext 4.0.7)!
Now about the "c:/fakepath" thing.. It's a browser specific security policy!
Chorme does the same.. Firefox doesn't!
You must to write a function to get rid of "fakepath"! Something like :

{
xtype: 'filefield',
id: 'licenseFile',
emptyText: "Enter the server path of the License File. eg : C:\\dg\\Customer2311641139962.lic",
name: 'licenseFile',
listeners: {
'change': function (filefield, value) {
value = value.replace('C:\\fakepath\\', '');
}
}
}

varunjyoti
19 Mar 2012, 4:47 AM
chramer,

Thanks for the reply. I understand the security policy thing. Regarding the first point, it there a way to fix it in my current version. For some reasons, i cant upgrade to 4.0.7.

margozzi
11 Jun 2012, 1:51 PM
It would be nice if Sencha would add a new method like getFileName() that returned only the file name and removed and path information. This way, every developer on earth need not implement the code above. personally i would not implement the onChange this way. In the future they may change c:\fakepath to something else. I plan to look fo rthe last path delimiter and remove everything up to that point. Also, if you run Chrome on Linux, is the slash likely to be the other way?