vbnet Upload a file

'<p><asp:FileUpload ID="FileUpload1" runat="server" /></p>

If FileUpload1.HasFile Then
	Dim FilePath As String = Server.MapPath("~") & "\uploads\"
	Dim s As New StringBuilder

	FileUpload1.SaveAs(FilePath & FileUpload1.FileName)

	s.Append("<p>File name: " & FileUpload1.PostedFile.FileName & "<br />")
	s.Append("File Size: " & (FileUpload1.PostedFile.ContentLength / 1024).ToString("#.00") & " kb<br />")
	s.Append("Content type: " & FileUpload1.PostedFile.ContentType & "<br />")
	s.Append("<a href=""/uploads/" & FileUpload1.FileName & """ target=""_blank"">View File</a></p>")
	s.Append("<p>Link to your file:<br /><textarea rows=""3"" cols=""35""><a href=""/uploads/" & FileUpload1.FileName & """>Link</a></textarea></p>")
	s.Append("<p>Image of your file:<br /><textarea rows=""3"" cols=""35""><img src=""/uploads/" & FileUpload1.FileName & """ alt="""" title="""" /></textarea><small><em>(remember to specify the <strong>alt</strong> and <strong>title</strong> attributes)<em></small></p>")

	Label1.Text = s.ToString
End If
Uploads a file using FileUpload control - as used on slickcms

Updated: Saturday 9th October 2010, 22:47pm

There are 0 comments

Leave a comment of your own

Comments are currently closed.