<%@ Page Language="VB" %>
<script language="VB" runat="server">
Sub Upload_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim strFileName, strRootUpload , strUniqueName As String
Dim index As Integer
strRootUpload = Server.MapPath("./upload")
lblMessage.Text = ""
If Not (fileInp.PostedFile Is Nothing) Then
Try
strFileName = fileInp.PostedFile.FileName
If strFileName <> "" Then
strFileName = strFileName.Replace("/", "\")
index = strFileName.LastIndexOf("\")
strFileName = strFileName.Substring(index + 1)
strUniqueName = System.Guid.NewGuid().ToString() + "_" + strFileName
fileInp.PostedFile.SaveAs(strRootUpload & "\" & strUniqueName)
lblMessage.Text = "Файлуспешнозагруженсименем " & strUniqueName & "<p>"
End if
Catch ex As Exception
lblMessage.Text = ex.Message & "<p>"
End Try
End If
End Sub
</script>
<HTML>
<HEAD>
<Title>Unique Upload</Title>
</HEAD>
<BODY>
<form enctype="multipart/form-data" runat="server">
<asp:Label id="lblMessage" runat="server" />
Файл:<br>
<input id="fileInp" type="file" runat="server"><br>
<asp:button text="Загрузить" OnClick="Upload_Click" runat="server" />
</form>
</BODY>
</HTML>
|