浏览器上传文件的问题
var file_upload=document.getElementById('图片上传').value;
该代码在两个浏览器中返回不同的值。
在 firefox 中,ie 返回 'filename.ext' 示例:test.jpg
但在 opera 中返回 'fullpath\filename.ext 示例:C:\fake_path\test.jpg
有谁知道这个问题吗
var file_upload=document.getElementById('picture-upload').value;
The code returns diffrent values in two browsers.
in firefox,ie returns 'filename.ext' example: test.jpg
but in opera returns 'fullpath\filename.ext example:C:\fake_path\test.jpg
Is any one knows the problem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
IE6 还会为您提供完整路径,而较新的浏览器仅提供文件名。这是为了安全。
我会检查名称中是否存在反斜杠或正斜杠,如果存在,则删除路径。
(该代码可能会收紧)
IE6 will also give you a full path, while newer browsers only give the file name. It's for security.
I would check for back or forward slashes in the name and if the exist, strip off the path.
(that code could probably be tightened up)