File Upload Sample

< %@ Page Language="VB" Debug="true" % >
< %@ import namespace="System.IO" % >

< language="VB" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
if page.isPostBack
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:\websites\articles\" & strFileName)
fileUploading.visible = false
msg.text = "File Uploaded ..."
end if
end sub
< /script >
<>
<>
< /head >
<>
< id="fileUploading" runat="Server" enctype="multipart/form-data">
<>Image :< /b > < id="strFile" type="file" runat="Server">
< type="submit" id="AddImage" value="Upload Image" runat="server">
< /form >
< id="msg" runat="server">

< /body >
< /html >

No comments:

Post a Comment