Login    Forum    Search    FAQ   Blog

Board index » Server Side Development » ASP 3.0




 Page 1 of 1 [ 4 posts ] 



Author Message
 Post subject: File uploadin and the Downloadin
 Post Posted: Sun Nov 22, 2009 10:08 pm 
Offline

Joined: Sat Feb 21, 2009 1:14 pm
Posts: 54
Hello!!! every one
Me wid C# asp.net

I would like to upload sum files (word files,setup,pdf etc) 2 a
folder and in anothr page I need to the list all da files nd then
download 4m dat page. How could I do this?


Thanks in advance


Top 
 Post subject: Re: File uploadin and the Downloadin
 Post Posted: Sun Nov 22, 2009 10:09 pm 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
Hi,

For Uplaodin the File..

http://msdn.microsoft.com/en-us/library/aa479405.aspx

http://www.aspheute.com/english/20000802.asp

see the above link..

for downlodin

U could provide da Simple link 4 the Downlaod


Top 
 Post subject: Re: File uploadin and the Downloadin
 Post Posted: Sun Nov 22, 2009 10:09 pm 
Offline

Joined: Sat Feb 21, 2009 1:08 pm
Posts: 549
Upload da files nd then store their name nd the
path in db

Later you could use GridView 2 show the files nd download


Top 
 Post subject: Re: File uploadin and the Downloadin
 Post Posted: Sun Nov 22, 2009 10:11 pm 
Offline

Joined: Sat Feb 21, 2009 2:16 pm
Posts: 41
Please refer da followin code...

that might be very usful to you.

Code:
# Sub Page_Load(sender As Object, e As EventArgs) 
#   
#   Dim root As String = "C:\temp\" 
#   
#   Dim files() As String = Directory.GetFiles(root) 
#   Dim sb As New StringBuilder(2048) 
#   Dim f As String 
#   For Each f In files 
#     Dim filename As String = Path.GetFileName(f) 
#     sb.Append("<br><a href=FileDownload.aspx?file=") 
#     sb.Append(root).Append(Server.UrlEncode(filename)) 
#     sb.Append(">").Append(filename).Append("</a>") 
#   Next 
#   fileList.Text = sb.ToString() 
#   
# End Sub


Code:
   1. <body> 
   2. <form runat="server"> 
   3. <asp:Label id="fileList" runat="server"/> 
   4. </form> 
   5. </body> 
   6. </html> 



Code:
   1. <br> 



Code:
   1. <span class="Apple-style-span" style="text-decoration: underline;">server side code</span> 




2. For File Upload

Client Code

Code:
   1. <form enctype="multipart/form-data" runat="server"> 
   2.   Select File to Upload:   
   3.   <input id="uploadedFile" type="file" runat="server"> 
   4.   <input type=button id="upload"   
   5.     value="Upload"   
   6.     OnServerClick="Upload_Click"   
   7.     runat="server"> 
   8. </form> 



Server code

Code:
   1. Dim savePath As String = "C:\temp\" 
   2. Sub Upload_Click(source As Object, e As EventArgs) 
   3.   
   4.   If Not (uploadedFile.PostedFile Is Nothing) Then 
   5.     Try 
   6.       Dim postedFile = uploadedFile.PostedFile 
   7.       Dim filename As String = Path.GetFileName(postedFile.FileName) 
   8.       Dim contentType As String = postedFile.ContentType 
   9.       Dim contentLength As Integer = postedFile.ContentLength 
  10.   
  11.       postedFile.SaveAs(savePath & filename) 
  12.       message.Text = postedFile.Filename & " uploaded" & _ 
  13.         "<br>content type: " & contentType & _ 
  14.         "<br>content length: " & contentLength.ToString() 
  15.     Catch exc As Exception 
  16.       message.Text = "Failed uploading file" 
  17.     End Try 
  18.   End If 
  19. End Sub   


Top 
Display posts from previous:  Sort by  
 
 Page 1 of 1 [ 4 posts ] 




Board index » Server Side Development » ASP 3.0


Who is online

Users browsing this forum: No registered users and 1 guest

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron