User Name Password Register
DaniWeb IT Discussion Community
All
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 403,106 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 3,197 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: 3722 | Replies: 1
Reply
Join Date: Aug 2005
Posts: 4
Reputation: jason_limwk is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
jason_limwk jason_limwk is offline Offline
Newbie Poster

download and upload

  #1  
Aug 3rd, 2005
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~
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2005
Posts: 494
Reputation: techniner is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 18
techniner techniner is offline Offline
Posting Pro in Training

Re: download and upload

  #2  
Aug 3rd, 2005
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
Did my post help?
Visit Little Jon's Web Portal


Generate Traffic with Maximum Traffic Software
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 2:04 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC