| Author: satyavani.namburu 17 Oct 2008 | Member Level: Bronze | Rating: Points: -20 |
Sub UploadImage() If Not (fileupload1.PostedFile Is Nothing) Then 'Check to make sure we actually have a file to upload
Dim strLongFilePath As String = fileupload1.PostedFile.FileName Dim intFileNameLength As Integer = InStr(1, StrReverse(strLongFilePath), "\") Dim strFileName As String = Mid(strLongFilePath, (Len(strLongFilePath) - intFileNameLength) + 2)
Select Case fileupload1.PostedFile.ContentType Case "image/pjpeg", "image/jpeg" 'Make sure we are getting a valid JPG image fileupload1.PostedFile.SaveAs(Server.MapPath("\") & strFileName) lbStatus.Text = strFileName & " was uploaded successfully to: " & Server.MapPath("\") & strFileName Case Else 'Not a valid jpeg image lbStatus.Text = "Not a valid jpeg image" End Select End If
End Sub
|
| Author: satyavani.namburu 17 Oct 2008 | Member Level: Bronze | Rating:  Points: 2 |
http://www.easerve.com/developer/tutorials/asp-net-tutorials-upload-image-file.aspx
|
| Author: Usha R 17 Oct 2008 | Member Level: Silver | Rating:  Points: 2 |
hi..
this s the sample code in c#..
u convert and write it in vb..
static byte[] pic;
string str = "Update tablename set Imgfield=@pic where ProdId='" + txtprodid.Text + "'"; SqlCommand command = new SqlCommand(str, Connection); int len = FileUpload1.PostedFile.ContentLength; pic = new byte[len]; int psize = len / 1024; if (psize < 512) { FileUpload1.PostedFile.InputStream.Read(pic, 0, len); command .Parameters.Add("@pic", pic); command .ExecuteNonQuery(); }
have a nice day...
Thanks & Regards Usha
|