首页 > 解决方案 > 使用用户上传的文件解析 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;
                    }

标签: c#asp.netwebforms

解决方案


推荐阅读