c# - 使用用户上传的文件解析 URL
问题描述
尝试解析发送到此 Web 表单中文件夹的上传 URL。该表单最初只允许上传 1 次,但现在他们想要添加更多,我不知道如何解析 URL,用户可以上传任意数量的表单,我已经包含了我现在拥有的代码。
protected void UploadButton_Click(object sender, EventArgs e)
{
if (fuSample.HasFile)
{
foreach (HttpPostedFile UploadButton in fuSample.PostedFiles)
try
{
string filename = Path.GetFileName(fuSample.FileName);
fuSample.SaveAs(Server.MapPath(ConfigurationManager.AppSettings["FileUploadFolder"]) + filename);
fileMessage.Text += String.Format("{0} <br />", UploadButton.FileName);
presentation.UploadPath += Server.MapPath(ConfigurationManager.AppSettings["FileUploadFolder"]) + filename;
UploadPathTextBox.Text = presentation.UploadPath;
}
catch (Exception ex)
{
fileMessage.Text = "Upload Status: The file(s) could not be uploaded. The following error occured: " + ex.Message;
}
解决方案
推荐阅读
- html - 服务器显示文本而不是 HTML
- reactjs - Redux Form,值在重新渲染时消失
- reactjs - 如何在安装 create-react-app 时修复“错误:spawn cmd ENOENT”?
- java - 将网页“图像”保存到变量以供以后使用硒进行处理
- javascript - 当用户在两个单选按钮之间进行选择时,如何让我的重定向成功运行?
- javascript - 如何根据文档中的参考 ID 合并和观察 Firestore 中的两个集合?
- html - 打印时如何使用内容制作单个 div 以填充整个页面
- php - 来自 SQL 条目的 PHP Tally Total - 最佳实践方法
- maven - 如何在 Maven Spring Boot 项目中引用配置文件
- c++ - 在 Clang 中以可移植和最佳方式将 uint64_t 转换为字节数组