•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 397,591 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,863 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 3701 | Replies: 1
![]() |
•
•
Join Date: Aug 2005
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
now iam doing a photo gallery in my site...(aspx in vb.net)
and i got some sample coding but mostly are in C#....recentuly i being redirected to a sample page and yupe// it looks good for me..~ but i am just wondering how can i do an upload function in my aspx (vb.net)?
the coding is too long for me to paste here..
but i am trying to say.. how to do in aspx (vb.net coding) when admin click a browse button... it will browse and then select and upload it to my /images/... and the the view.aspx will display the photo?
something like upload and download function? can anyone help ? thanks....
if you nid to email me.. i am available at any time... jasonlimwk@gmail.com
thanks for the help~
and i got some sample coding but mostly are in C#....recentuly i being redirected to a sample page and yupe// it looks good for me..~ but i am just wondering how can i do an upload function in my aspx (vb.net)?
the coding is too long for me to paste here..
but i am trying to say.. how to do in aspx (vb.net coding) when admin click a browse button... it will browse and then select and upload it to my /images/... and the the view.aspx will display the photo?
something like upload and download function? can anyone help ? thanks....
if you nid to email me.. i am available at any time... jasonlimwk@gmail.com
thanks for the help~
•
•
Join Date: May 2005
Posts: 494
Reputation:
Rep Power: 4
Solved Threads: 18
Work off this sample:
Sub btnUpload_Click (Sender as Object, e as EventArgs)
If Not (ctlFileImage.Posted is Nothing) Then
With ctlFileImage.Posted
Dim lngFileSize as Long = .ContentLength ‘//Size in Bytes upload file
Dim sContentType as String = .ContentType ‘//Returned by MINE type
Dim sFileName as String =.FileName ‘//Client File Name and Path
‘//Size Check if you do not require it then comment the following if
If (lngFileSize / 1024) > 10 Then ‘// If file size is over 10Kb
lblError.Caption += “File Size Too Much {:-o�
lblError.Visible = True
Exit Sub
End If
‘//File Type Filteration: add any type and add the code to you specific type
Select Case Trim (sContentType.ToLower)
‘// Filter the file types that are sent by the browser
Case "image/gif", "image/pjpg", "image/jpeg", "image/pjpeg", "image/jpg"
Try
‘// Save the file to the server if you cannot save it then see the Errors ‘//Details Section below almost at end of the article
‘//Get only filename.ext by using IO Class no path as we use our own path
sFileName = System.IO.Path.GetFileName (.FileName)
.SaveAs (Server.MapPath (“/project/users_imgs/�) & sFilename)
‘// you can also code here to store this picture in SQL server rather ‘// than saving on the server
‘// That will be my next version of this article :-)
‘// Now file is uploaded but what about the description of the picture.
‘// in ASP.NET all the controls persist their values in the server round
‘// cycles so you donot worry about the value of txtDesc it will be
‘// there as normal. So you can now use the txtDesc.Text and image
‘// path to store in the databse
Dim conn as New System.Data.SqlClient.SqlConnection (Your Connection String)
Dim cmd as New System.Data.SqlClient.SqlCommand
With cmd
.CommandText = “your update or insert query that use txtDesc.Text and other controls�
.Connection = conn
.CommandType = CommandType.Text
If Conn.State = ConnectionState.Closed Then Conn.Open ()
.ExecuteNonQuery ()
End With
Catch ex As Exception
lblError.Caption += ex.ToString
lblError.Visible = True
Exit Sub
End Try
Case Else
lblError.Caption += “Invalid File Type Only Pictured are required.�
lblError.Visible = True
Exit Sub
End Select
End With
End Sub![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
.net .net framework 3.0 access adsl adsl1 adsl2 adsl2+ ajax asp cable code combo connection custom data developer development dom download dropdownlist feed internet kb kbps mbit microsoft module msdn net network office per reader reuse second skin software sql testing theme throughput upload vista weather web windows windows workflow xml xoap 240000
- Internet Speeds (Web Browsers)
- Lap Top Advice - Which to buy (Techies' Lounge)
- What do you pay for your :: Internet Connection? (Geeks' Lounge)
- Slow Web Browsing (Web Browsers)
- Optonline web/email hosting (Networking Hardware Configuration)
- Upload/Download Script... with compression? (PHP)
- Changing ISP (Web Browsers)
Other Threads in the ASP.NET Forum
- Previous Thread: about confirm message box
- Next Thread: email button in mail.body


Linear Mode