1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| <%@ Import namespace="System.IO"%>
<html>
<head>
<title>Uploading a File</title>
<script language="VB" runat="server">
Dim savePath As String = Server.MapPath(".") & "\"
Sub Upload_Click(source As Object, e As EventArgs)
If Not (uploadedFile.PostedFile Is Nothing) Then
Try
Dim postedFile = uploadedFile.PostedFile
Dim filename As String = Path.GetFileName(postedFile.FileName)
Dim contentType As String = postedFile.ContentType
Dim contentLength As Integer = postedFile.ContentLength
postedFile.SaveAs(savePath & filename)
message.Text = postedFile.Filename & " uploadé" & _
"<br />destination : " & savePath & filename & _
"<br>content type: " & contentType & _
"<br>content length: " & contentLength.ToString()
Catch exc As Exception
message.Text = "Erreur lors de l'upload : " & exc.ToString()
End Try
End If
End Sub
</script>
</head>
<body>
<form enctype="multipart/form-data" runat="server">
Fichier à uploader :
<input id="uploadedFile" type="file" runat="server">
<p>
<input type=button id="upload"
value="Upload"
OnServerClick="Upload_Click"
runat="server">
<p>
<asp:Label id="message" runat="server"/>
</form>
</body>
</html> |