PDA

View Full Version : Removing 'fakepath' from fileuploadfield in 4.1.1



zeke
27 Sep 2012, 9:30 AM
Is there a good way to remove the 'fakepath' stuff from the displayed value in a file upload field so instead of something like "c:\fakepath\myfile.txt" it displays only the filename (myfile.text) instead?

I thought I might be able to do this through setValue but it doesn't do anything any more, for good reason I'm sure.

Also, not sure if this is frowned upon, but in using the new forum search functionality (which I really like btw!) it looks like this question may have been asked in the premium forums: http://www.sencha.com/forum/showthread.php?240197

scottmartin
1 Oct 2012, 5:38 AM
You would have to display the path yourself. The browser add fakepath this as a security feature.

Scott.

zeke
2 Oct 2012, 6:09 AM
Adding the following to the fileuploadfield config is working for me:



listeners: {
change: function(f,v){
var node = Ext.DomQuery.selectNode('input[id='+f.getInputId()+']');
node.value = v.replace("C:\\fakepath\\","");
}
},

louisthach
26 Dec 2012, 5:55 PM
Adding the following to the fileuploadfield config is working for me:



listeners: {
change: function(f,v){
var node = Ext.DomQuery.selectNode('input[id='+f.getInputId()+']');
node.value = v.replace("C:\\fakepath\\","");
}
},


Thanks Zeke, this really works for me too.

lawrence_o
20 Sep 2016, 11:01 PM
Adding the following to the fileuploadfield config is working for me:



listeners: {
change: function(f,v){
var node = Ext.DomQuery.selectNode('input[id='+f.getInputId()+']');
node.value = v.replace("C:\\fakepath\\","");
}
},



A big thanks from here as well, Zeke: works for me too :-D