简体   繁体   English

在ASP.NET中处理上传的文件

[英]Work with an uploaded file in ASP.NET

I need to create a custom web control which will be a part of a class library. 我需要创建一个自定义Web控件,它将成为类库的一部分。 This custom web control implements the upload functionality. 此自定义Web控件实现了上传功能。 I have implemented this with a web user control where I have a fixed path to a page in the web project where the upload of files take place and it works just fine. 我已经通过一个Web用户控件实现了此操作,在该控件中我有一个指向Web项目中页面的固定路径,在该页面中可以进行文件上传,并且效果很好。

The created control in this class library is used in the web project. 该类库中创建的控件在Web项目中使用。 How do I post the uploaded file to a page, say SomeClass.cs, in the class library. 如何将上传的文件发布到类库中的页面,例如SomeClass.cs。

Thanks in advance. 提前致谢。

您可以使用文件上传控件将文件发布到代码隐藏文件中。

将系统路径作为字符串重载传递?

string systemPathToFile = Server.MapPath("~/UploadedFiles/" + Path.Filename(fuFileUpload.Filename));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM