帮助我从fileupload控件获取文件的路径 [英] help me to get the path of a file from fileupload control
本文介绍了帮助我从fileupload控件获取文件的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在C#中使用代码时
when i use the code in C#
string fullPath = Server.MapPath(fileupload1.PostedFile.FileName);
我希望结果为
C:\ Documents and Settings \ rajkumar.t \ Desktop \ vCard.vcf
但我得到的结果是
C:\ Documents and Settings \ rajkumar.t \ Desktop \ CRM \ form \ vCard.vcf
CRM/form是我的项目,文件上传控件在这里.
我必须增强什么?
i want the result as
C:\Documents and Settings\rajkumar.t\Desktop\vCard.vcf
but i got result as
C:\Documents and Settings\rajkumar.t\Desktop\CRM\form\vCard.vcf
CRM/form is my project the fileupload control is here.
what i have to enhance?
推荐答案
try
Server.MapPath(FileUpload1.FileName);
希望对您有所帮助.
try
Server.MapPath(FileUpload1.FileName);
Hope it helps.
您不能可靠地进行操作.安全禁止这样做,因为它会(尽管是间接地)提供有关客户端硬件的信息.
您还是无法使用它-无法将其重新加载到原始位置,因为客户端浏览器可以控制它的去向,而不是您.
IE将返回路径(排序),FF将仅返回名称,依此类推.
You can''t, reliably. Security forbids this, as it would give information (albeit indirectly) about the client hardware.
You can''t use it anyway - there is no way to reload it to the original location, as the client browser has control over where it goes, not you.
IE will return a path (sort of), FF will return only the name, and so on.
您必须手动从路径字符串中删除最后一个文件夹名称.
本文介绍了解决方案,
http ://www.dotnetheaven.com/uploadfile/prathore/how-to-find-last-index-of-the-string-in-Asp-Net-using-C-Sharp/ [ ^ ]
you have to mannualy remove last folder names from your path string.
the article describes the solution,
http://www.dotnetheaven.com/uploadfile/prathore/how-to-find-last-index-of-the-string-in-Asp-Net-using-C-Sharp/[^]
这篇关于帮助我从fileupload控件获取文件的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文