Effettuare l'upload di files sul server
<%@ Page Language="VB" Debug="true" %>
<%@ import namespace="System.IO" %>
<script language="VB" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
if page.isPostBack
try
Dim strFilePath As String = strFile.PostedFile.FileName
Dim i As Integer = InStr(1, StrReverse(strFilePath), "\")
Dim strFileName As String = Mid(strFilePath, (Len(strFilePath) - i) + 2)
strFile.PostedFile.SaveAs("c:\wwwroot\inetpub\myWeb\" & strFileName)
messaggio.text = "File Salvato ..."
catch
messaggio.text = "Errore nel salvataggio ..."
end try
end if
end sub
</script>
<html>
<head>
</head>
<body>
<form id="fileUpload" runat="Server" enctype="multipart/form-data">
File: <input id="strFile" type="file" runat="Server" />
<input type="submit" id="UploadFile" value="Upload File" runat="server" />
</form>
<asp:label id="messaggio" runat="server"/>
</body>
</html>
Scarica il Codice...
Stampa la pagina