Код: Выделить всё
protected void saveFilesToForm_Click(object sender, EventArgs e){
string savePathFile = "uploads/MyWebsite/";
List fileUrls = new List(); // List to store file URLs
if (formFileMultiple.HasFile) // Check for multiple files
{
foreach (HttpPostedFile file in formFileMultiple.PostedFiles)
{
string fileNameUpload = ViewState["webform_id"] + "-" + file.FileName;
string fullPath = Server.MapPath("~/" + savePathFile + fileNameUpload);
// Save the file to the server
file.SaveAs(fullPath);
// Create file URL
string fileUrl = ResolveUrl("~/" + savePathFile + fileNameUpload); // Generates a relative URL to the uploaded file
fileUrls.Add(fileUrl); // Add to the list of URLs
}
// Generate HTML for links
string linksHtml = string.Join("
", fileUrls.Select(url => "[url=\]" + url + "[/url]"));
// Set the text of the filePathURL control
filePathURL.Text = linksHtml;
}
else
{
savePathFile = null;
filePathURL.Text = "No files uploaded";
}}
File Upload
[url=
Подробнее здесь: [url]https://stackoverflow.com/questions/79244399/file-upload-presenting-404-error-on-c-asp-net[/url]
Мобильная версия