我在VB.NET中有一個代碼只是爲了上傳ASP.NET WebForm中的文件。它在Firefox,Chrome和Safari中完美運行。但是相同的代碼無法將上傳的文件保存在Microsoft Internet Explorer和Microsoft Edge中,但應用程序中沒有任何錯誤或異常。我需要某人的幫助來解決這個問題。我的.aspx代碼和代碼隱藏文件的代碼是如下:Fileupload無法在Microsoft IE和Microsoft Edge瀏覽器中使用ASP.NET WebForm
WebForm1.aspx的
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="FileUploadTest.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="Uploader" runat="server" />
<asp:Button ID="cmdUpload" runat="server" Text="Upload" />
</div>
</form>
</body>
</html>
代碼隱藏文件
Imports System.IO
Public Class WebForm1
Inherits Page
Dim uploadDirectory As String = "C:\Uploads\"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub cmdUpload_Click(sender As Object, e As EventArgs) Handles cmdUpload.Click
Dim uniqueGuid As String = Guid.NewGuid.ToString
Dim tmpUploadDirectory As String = uploadDirectory & "\" & uniqueGuid
If Not Directory.Exists(tmpUploadDirectory) Then
Directory.CreateDirectory(tmpUploadDirectory)
End If
For Each f As HttpPostedFile In Uploader.PostedFiles
f.SaveAs(Path.Combine(tmpUploadDirectory, f.FileName))
Next
End Sub
End Class