| | |
download and upload
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2005
Posts: 4
Reputation:
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: 514
Reputation:
Solved Threads: 19
Work off this sample:
ASP.NET Syntax (Toggle Plain Text)
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
![]() |
Similar Threads
- Internet Speeds (Web Browsers)
- Lap Top Advice - Which to buy (IT Professionals' 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
| Thread Tools | Search this Thread |
.net 2.0 3.5 ajax alltypeofvideos appliances asp asp.net beginner box browser businesslogiclayer button c# cac checkbox class commonfunctions compatible content contenttype control countryselector courier dataaccesslayer database datagrid datagridview datalist deployment development dgv dialog dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv gridview gudi iis javascript list listbox login menu microsoft mouse mssql nameisnotdeclared news novell numerical opera order panelmasterpagebuttoncontrols problem radio ratings redirect registration relationaldatabases reportemail schoolproject search security serializesmo.table sessionvariables silverlight smoobjects software sql sql-server sqlserver2005 ssl tracking treeview validatedate validation vb.net videos vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment webprogramming webservice wizard xsl youareanotmemberofthedebuggerusers





