Receiving fake path while uploading

2019-01-28 22:07发布

Whenever the uploading process happens through the Browsers rather than IE, the path
belongs to the file from client side systems is showing like "c:/fakepath/x.jpg"..! I tried out lot of
Solutions from the web to rectify that, but nothing works..! If anybody successfully tackled this
problem before Just send me your solution..!
HTML code that i used

<form name="xx"  enctype="multipart/form-data">
<input type="file" name="up"/>
</form>

My Java script..

alert(document.xx.up.value);

But it is displaying "c:/fakepath/x.jpg" in all browsers except IE.

4条回答
疯言疯语
2楼-- · 2019-01-28 22:30

This post shows a way to remove the 'fakepath' display:

// Change the node's value by removing the fake path

inputNode.value = fileInput.value.replace("C:\fakepath\", "");

查看更多
冷血范
3楼-- · 2019-01-28 22:41

Modern browsers won't tell you what the actual path of the file is, because it's really none of your business as an application programmer, and is likely to contain private user information (e.g, their username).

There is no workaround. Learn to live without that information.

查看更多
疯言疯语
4楼-- · 2019-01-28 22:44

This is a browser security restriction. You can't set the value of the file upload control via script, nor can you read the correct path.

查看更多
走好不送
5楼-- · 2019-01-28 22:44

Change the ClientId of the AsyncFileUpload control from Inherit to AutoId

查看更多
登录 后发表回答