Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 5th, 2004, 02:03 PM
Registered User
 
Join Date: Jan 2004
Location: London, , United Kingdom.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default file upload and download

I would like to create a .net web service for downloading and uploading a excel or text file.

How to do that? Is there any sample code / article available?

Thanks

Thanks and regards
Siva
Reply With Quote
  #2 (permalink)  
Old February 5th, 2004, 02:36 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

What do you mean? Do you want a user to upload/download the file?
Reply With Quote
  #3 (permalink)  
Old February 6th, 2004, 05:39 AM
Registered User
 
Join Date: Jan 2004
Location: London, , United Kingdom.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, you are right. Using the Web Service, the user should be able to upload and download file. How to do that?

Thanks and regards
Siva
Reply With Quote
  #4 (permalink)  
Old February 6th, 2004, 01:23 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You don't. That's not what web services are for. Web services are designed for the purposes of providing data over HTTP using XML. This data is used, or "consumed" by other applications. Web services are designed as a end use interface. You need to create a web form to do this. Try this google search for help on how to upload files using ASPX web forms.

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #5 (permalink)  
Old February 15th, 2004, 08:13 AM
Registered User
 
Join Date: Feb 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No.It's very easy to upload or download any document with web services. Here is a sample example :

This is for web services :


<WebMethod()> PublicFunction UploadFile(ByVal fs()As Byte,ByVal FlName As String)As String
  Try
      Dim m As New MemoryStream(fs)
      Dim f As New FileStream("c:\tempUploaded\" & FlName, FileMode.Create)
      m.WriteTo(f)
      m.Close()
      f.Close()
      f = Nothing
      m = Nothing
      Return "File Uploaded"

  Catch ex As Exception
    Return ex.Message
  End Try
End Function

Note: You must import System.IO
--------------------------------------

This is for your asp.net file (or win app)

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  Try
    Dim f As System.IO.File
    Dim fs As System.IO.FileStream
    Dim o As New localhost.Service1()
    'file to upload
    fs = f.Open("c:\upload.pdf", IO.FileMode.Open, IO.FileAccess.Read)
    Dim b(fs.Length - 1) As Byte
    fs.Read(b, 0, fs.Length)
    MsgBox(o.UploadFile(b, "upload.pdf"))
    f = Nothing
    fs.Close()
  Catch ex As Exception
    MsgBox(ex.Message)
  End Try
End Sub



Reply With Quote
  #6 (permalink)  
Old February 16th, 2004, 12:27 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

okantekeli,

Right, so you have confirmed my point. The web service doesn't provide the capability to upload/download the file. You must create a user interface (ASP.net or winforms application) that provides the capability to deal with the user's local file(s) and then could use the web service to take the file as a byte stream and do whatever it needs with it. In the case of an ASP.net web application, you actually need to upload/download the file in the context of an HTTP connection (between the server and the browser). In the case of a winforms application, you are dealing with the file locally and thus you aren't actually doing any upload/download per se. What you do with the application internally is irrelevant. In the case of your example, you have a web service that handles a byte stream and dumps it to a file and you have a winform app that handles a file locally and uses the web service. The point remains that the web service itself is not providing the "upload/download" capability.

This discussion is really a matter of semantics. The real question that should be posed is: What is the ultimate goal regarding the original post? Is the desired result a web interface to upload/download a file? If so, then okantekeli's suggestion can be implemented as described. The web interface is doing the uploading and downloading, it just happens to use a web service instead of a local file IO.

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #7 (permalink)  
Old February 19th, 2005, 04:17 PM
Registered User
 
Join Date: Feb 2005
Location: Kuttawa, KY, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This works great on my local machine; how can you use another web server with this. I'm using a VB.NET app to send the file and can't figure out how to specify another web server other than local.

Thanks!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue in Upload/download FTP file via Proxy C#.NET naveenh C# 3 June 20th, 2008 08:51 AM
upload-download video vipin k varghese PHP How-To 2 May 9th, 2008 03:39 AM
Upload and download section patzie ASP.NET 1.x and 2.0 Application Design 0 September 19th, 2005 04:37 AM
Please Help: ASP file upload and download vtcyee Classic ASP Components 1 July 10th, 2004 06:21 AM
About file upload and download using ASP vtcyee Classic ASP Databases 1 July 10th, 2004 12:27 AM



All times are GMT -4. The time now is 12:29 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.