locked
problem with web service file upload RRS feed

  • Question

  • User1131230065 posted

    Hi, 

    This is my first time working with webservices so I create a simple one to upload files but I had a problem with it I hope if someone could help me :

    ""

     Dim fileName As String = Uploader.FileName()

    Dim destPath As String = Path.Combine(destDir, fileName)

    Uploader.PostedFile.SaveAs(destPath)

    Return "Thanks for submitting your file."

    ""

    It told me that FileName() is not a member of string , but when I try (File Upload Control ) on a website it work but when I move  the code to the webservice it doesn't !!!

    I think it maybe because the Uploader ( It's the ID of my File Upload Control which I put it on the website  Uploader.FileName() ), maybe the webservice couldn't declared it because it's on file.aspx page in my website !!

    Thanks,

    FAdam

    Friday, April 26, 2013 5:58 AM

Answers

  • User220959680 posted

    because the Uploader ( It's the ID of my File Upload Control which I put it on the website  Uploader.FileName() ), maybe the webservice couldn't declared it because it's on file.aspx page in my website

    Web Service implements the POST method to receive file stream and insert into database or store it some where.

    Web application consumes the above service method.

    In .aspx file code behind Web Service is called passing the file as Stream. Web service is not at client end, so your above copied source throws exceptions.

    Refer:- http://www.codeproject.com/Articles/166763/WCF-Streaming-Upload-Download-Files-Over-HTTP

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 26, 2013 9:46 AM

All replies

  • User220959680 posted

    because the Uploader ( It's the ID of my File Upload Control which I put it on the website  Uploader.FileName() ), maybe the webservice couldn't declared it because it's on file.aspx page in my website

    Web Service implements the POST method to receive file stream and insert into database or store it some where.

    Web application consumes the above service method.

    In .aspx file code behind Web Service is called passing the file as Stream. Web service is not at client end, so your above copied source throws exceptions.

    Refer:- http://www.codeproject.com/Articles/166763/WCF-Streaming-Upload-Download-Files-Over-HTTP

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 26, 2013 9:46 AM
  • User1131230065 posted

    FAdam

    because the Uploader ( It's the ID of my File Upload Control which I put it on the website  Uploader.FileName() ), maybe the webservice couldn't declared it because it's on file.aspx page in my website

    Web Service implements the POST method to receive file stream and insert into database or store it some where.

    Web application consumes the above service method.

    In .aspx file code behind Web Service is called passing the file as Stream. Web service is not at client end, so your above copied source throws exceptions.

    Refer:- http://www.codeproject.com/Articles/166763/WCF-Streaming-Upload-Download-Files-Over-HTTP

    Hi Sukumarraju,

    Thanks for replay ,my problem is how could I make my webservice get the file information such as filename and path which the user entered in  is in FileUpload control and save this information on specific Path (             Dim destDir As String = Server.MapPath("./Data/Public") )

    and this example in C# but I work with VB.NET so I don't understand it very well 

    Thanks again,

    FAdam

    Friday, April 26, 2013 3:19 PM
  • User-1658256289 posted

    Hi, you can use a tool here to convert c# code to vb.

    http://www.developerfusion.com/tools/convert/csharp-to-vb/

    Wednesday, May 1, 2013 4:18 AM
  • User1131230065 posted

    Thanks alot Nico_He Smile

    FAdam

    Saturday, May 4, 2013 2:46 PM