PDA

View Full Version : Extjs: filefield - Fake path, while uploading a file



madhu.vistex
16 Dec 2013, 4:58 AM
Hi,
I am trying to upload a file using filefield component of Extjs..I am able to upload the file, but it is showing C:/fakepath/<filename> in file input field (and sending the same fakepath to server) instead of its original path...i need to send original path in server request to do some process with original path....
I knew that it is because of browser script for security purpose...but, at least it is not sending the original path to server request...

Here is the code, that i programmed...

Ext.define('Note.view.Attachment', {
extend: 'Ext.form.Panel',
xtype: 'x_attachment',
header: false,
border: false,
items: [
{
xtype: 'filefield',
name: 'Attachment',
id: 'Attachment',
fieldLabel: 'File Path',
labelWidth: 100,
msgTarget: 'side',
border: false,
buttonText: 'select'
}
],
buttons: [ {
text: 'Upload',
handler: function () {
var form = this.up('form').getForm();
if (form.isValid()) {
form.submit({
url: 'fileUpload.php',
waitMsg: 'Uploading your file...',
success: function (fp, o) {
Ext.Msg.alert('File has been uploaded');
********Server call code***************
},
failure: function () {
}
});
}
}
}
]
});

cwtuan
16 Dec 2013, 6:58 AM
Use applet.

madhu.vistex
16 Dec 2013, 7:01 AM
Use applet.


Can you provide sample example or sample code

existdissolve
16 Dec 2013, 9:03 PM
Hi,
I am trying to upload a file using filefield component of Extjs..I am able to upload the file, but it is showing C:/fakepath/<filename> in file input field (and sending the same fakepath to server) instead of its original path...i need to send original path in server request to do some process with original path....
I knew that it is because of browser script for security purpose...but, at least it is not sending the original path to server request...


The end of the story is that you're not going to be able to "send the original path" to the server because 1.) that would be horribly insecure (like telling a remote server all about the details of your local machine) and 2.) that's simply not how HTTP file uploads work.

If you need the original file path, you'll need to revisit what it is you're trying to accomplish, since the only way you're going to be able to get that is if you convince your users to type that information in verbatim.