如何在文件上传中使用javascript获取原始文件路径 [英] How to Get the Original file path using javascript in file upload

查看:65
本文介绍了如何在文件上传中使用javascript获取原始文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的专家,



我正在做一个ASP.net项目。在该项目中我使用Ajax JSON来传输数据。



我正在使用Javascript从控件读取数据。



但是我遇到了问题,



当我使用文件输入HTML控件时,我没有得到原始文件路径...



在Chrome中我得到



 C:\ fakepath \ DSC101。 





在Mozzilla



 DSC101.jpg 





但我需要完整的原始路径上传文件....



HTML控制



<前lang =HTML> < < span class =code-leadattribute> input type = file name = file-input id = FIP_PIC < span class =code-attribute> value = class = 文件验证[必需] < span class =code-keyword>>





JAVASCRIPT读取文件路径。



  var  _Profile_PIC =  document  .getElementById('  FIP_PIC')。value; 





如何使用javascript获取原始路径...



请帮助我...



谢谢&问候,



Dileep

解决方案

http://forums.asp.net/t/1333198.aspx/1 [ ^ ]


你不能。

安全停止你知道有关客户端计算机文件系统的任何信息 - 它甚至可能没有!它可能是MAC,PC,平板电脑或支持互联网的冰箱 - 你不知道,不知道也不会知道。让你有完整的路径可以给你一些关于客户端的信息 - 特别是如果它是一个网络驱动器。



事实上,你可以得到它特定的条件,但它需要一个ActiveX控件,并不会在99.99%的情况下工作。



你不能用它来将文件恢复到原来的位置无论如何(因为你完全无法控制下载的存储位置,或者即使存储它们),所以在实践中它对你来说并没有多大用处。


Dear Experts,

I am Doing an ASP.net project. In that project am using Ajax JSON to transfer the datas.

And am Using Javascript to read the datas from controls.

But I am facing a Problem,

I didn''t get the Original File path when i used the file Input HTML Control...

In Chrome i get

C:\fakepath\DSC101. 



And in Mozzilla

DSC101.jpg



but i need the full original path to upload the file....

HTML CONTROL

<input type="file" name="file-input" id="FIP_PIC" value="" class="file validate[required]">



JAVASCRIPT to read the file path.

var _Profile_PIC = document.getElementById('FIP_PIC').value;



How to get the original Path using javascript...

Please help me...

Thanks & regards,

Dileep

解决方案

http://forums.asp.net/t/1333198.aspx/1[^]


You can''t.
Security stops you for knowing anything about the filing system of the client computer - it may not even have one! It could be a MAC, a PC, a Tablet or an internet enabled fridge - you don''t know, can''t know and won''t know. And letting you have the full path could give you some information about the client - particularly if it is a network drive for example.

In fact you can get it under particular conditions, but it requires an ActiveX control, and will not work in 99.99% of circumstances.

You can''t use it to restore the file to the original location anyway (as you have absolutely no control over where downloads are stored, or even if they are stored) so in practice it is not a lot of use to you anyway.


这篇关于如何在文件上传中使用javascript获取原始文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆