在File Uploader中发布文件的FullPath? [英] FullPath of posted File in File Uploader?

查看:77
本文介绍了在File Uploader中发布文件的FullPath?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我阅读了有关
的文章 说
"PostedFile.FileName"
FileUploader的属性返回完整路径
上传的文件,例如"c:\ .."
但它会继续仅返回上载文件的文件名
就像"test.txt"一样

我不知道为什么.

这是我的代码

asp:

< asp:FileUpload ID ="QestionsFU" runat ="server"/>

C#
String filename = QestionsFU.PostedFile.FileName;

I read Articles that
Says
"PostedFile.FileName"
property of A FileUploader returns the fullpath
of the uploaded file like "c:\.."
but it keeps on returning only the File name of the uploaded file
like "test.txt"

I don''t know why.

here is my code

asp:

<asp:FileUpload ID="QestionsFU" runat="server" />

C#
String filename=QestionsFU.PostedFile.FileName;

推荐答案

您不能-安全性使您无法了解浏览器背后的机器.
无论如何,您都不需要它-您无法通过从用户那里下载文件来还原到该文件,因为他们会选择文件的存放位置...
You can''t - security prevents you knowing anything about the machine behind the browser.
You don''t need it anyway - you cannot restore to it by download from the user as they will select where the file goes...


出于安全原因,大多数浏览器(我不会100%肯定,这就是为什么我最多说)不会发送完整路径,仅发送文件名.您永远不需要完整的路径.
Due to security reasons most browsers (Im not 100% sure, thats why I say most) wont send the entire path, only the file name. You should never need the entire path.




您应该知道您的应用程序在哪里保存文件,如果这样很容易获得完整的路径名,
Hi,

You should know where your application is saving files, if so getting full path name is easy,
String filename=QestionsFU.PostedFile.FileName; 


这实际上返回了客户端文件名.表示指定文件的路径.假设您的应用将所有文件保存在服务器的C:\ UPLOADED_FILES \下.
那么完整的文件名将是


this actually returns the client filename. Meaning the path to the specified file. Supposed your app save all files under C:\UPLOADED_FILES\ in server.
then full file name will be

String filename="C:\UPLOADED_FILES\"+QestionsFU.PostedFile.FileName;


所以您现在拥有完整的路径.


so you have the full path now.


这篇关于在File Uploader中发布文件的FullPath?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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