开发者

How do I upload a file without browsing for the file?

I am learning how to work with FileUpload control in ASP.NET. I am a little开发者_StackOverflow中文版 curious whether tis possible to upload a file without having to browse for it, that is, by knowing the path of the file I want to upload.

Pseudo Example:

 filepath = "C:\temp\file.txt"
 FileUpload1.SaveAs( ..., filepath ,...)

If this is not possible, is there a way to perform this by using other ways like httppostfile, etc...?


For security reasons, browsers typically prevent access to local file system objects that have not been selected by the file upload.

Most file uploads also require a human action to select the file path; that is, they prevent the file path from being specified with JavaScript.


What if you changed your code to:

filepath = "C:\documents\mypasswords.txt"
FileUpload1.SaveAs( ..., filepath ,...)

and this file was uploaded automatically to your server without me, as a user of your site, knowing about it? Well, I wouldn't be a happy user of your site. So luckily that's not possible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜