View Full Version : fakepath on file upload?

10 Jan 2012, 8:00 AM
I may be missing something here but I don't understand why Extjs uses "fakepath" as the value for the location of the file when you select a file for upload.

10 Jan 2012, 8:09 AM
The path is not known due to browser security

12 Jan 2012, 9:03 AM
So is the "fakepath" only displayed for security reasons and does the image file actually get loaded? Or do you have to somehow process the path behind the scene to point it to the actual path in order to actually get the file?

12 Jan 2012, 9:08 AM
the path isn't available to javascript, the browser won't give it to us

12 Jan 2012, 1:08 PM
Okay, I got that. Here's another question. I'm trying to understand why my response is returning false.

After this line executes, "result = this.processResponse(response)" result is still null. This is in the "ext-all-dev.js" file.

onSuccess: function(response) {
var form = this.form,
success = true,
result = this.processResponse(response);
if (result !== true && !result.success) {
if (result.errors) {
this.failureType = Ext.form.action.Action.SERVER_INVALID;
success = false;
form.afterAction(this, success);

Here's my php script to handle the upload image.

$target = "upload/";
$target = $target . basename( $_FILES["file"]["name"]) ;
if(move_uploaded_file($_FILES["file"]["tmp_name"], $target)) {
echo "The file ". basename( $_FILES["file"]["name"]). " has been uploaded";
echo "Sorry, there was a problem uploading your file.";

I made it simple just to get uploading an image working first before putting in validations for file type, size, etc. Also, how do you tell if the php script actually execute and the correct file is sent?

12 Jan 2012, 2:27 PM
For form submits... you should return JSON

"success" : true

12 Jun 2014, 10:23 AM
When we select a document in a file field, it shows us some thing like thisC:\fakepath\Dummy.txt.. But when press browse again and select cancel it removes our previous selection. For this not to happen I did the below. I had a change listener and made sure when the new value is empty then set the value of the object with old value.
change: function(obj,nv,ov){
var selectedValue = ov;
if(nv.length === 0){
var value = obj.setRawValue(obj.processRawValue(ov));

On the screen it shows fine that it is set, but the file is not being uploaded when i did a form submit. while checking this approach. Is there anything i am missing in particular ???