Rabu, 04 Maret 2009
Cara Upload Foto Di ASP. Net by Muhajir
'Create by Muhajir
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ' Image1.ImageUrl = FileUpload1.FileName If Not File1.PostedFile Is Nothing And File1.PostedFile.ContentLength > 0 Then Dim fn As String = System.IO.Path.GetFileName(File1.PostedFile.FileName) Dim SaveLocation As String = Server.MapPath("Data") & "\" & fn Dim SaveFile As String = fn Try TextBox1.Text = SaveLocation File1.PostedFile.SaveAs(SaveLocation) Response.Write("The This file has been uploaded.") 'http://Localhost/test/ 'Image1.ImageUrl = "~/data/logo.gif" 'directory di d:/test/data/logo.gif Image1.ImageUrl = "~" & "/data/" & SaveFile 'directory di d:/test/data/logo.gif tampilkan foto Catch Exc As Exception Response.Write("Error: " & Exc.Message) End Try Else Response.Write("Please select a file to upload.") End If
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar