Recieve a file via HTTP POST to a webservice

Discussion in 'ASP .Net Web Services' started by Saddergoat, Sep 5, 2003.

  1. Saddergoat

    Saddergoat Guest

    Hi,

    I am trying to upload a file from a form via POST to a
    webservice (VB.NET).

    If I set enctype='multipart/form-data' on the form I get a
    500 error.

    If I don't the submission results in a error saying that
    the file cannot be converted to type Byte.

    Any suggestions would be most appreciated.



    My html form code is:

    <html>
    <body>
    <h3> Upload Shape File </h3>
    <hr />
    <form name='uploadShape' method='POST'
    action='http://localhost/TEClientAdmin/Service1.asmx/addSha
    pe' >
    Name: <input name='shapeName'
    type='text' /> <br />
    shp file: <input name='shp()'
    type='file' /> <br />
    <input type='submit'
    value='Upload' />
    </form>
    </body>
    </html>

    My webmethod is:

    <WebMethod()> Public Function addShape(ByVal shp() As
    Byte, ByVal shapeName As String, ByVal authUser As String,
    ByVal authPwd As String) As String
    Dim shapeRoot As String = "c:\"
    Try
    'Dim memStream As New System.IO.MemoryStream
    (shp)
    'Dim fStream As New System.IO.FileStream
    (shapeRoot & shapeName & ".shp",
    System.IO.FileMode.Create.Create)

    'memStream.WriteTo(fStream)
    'memStream.Close()
    'fStream.Close()

    'fStream = Nothing
    'memStream = Nothing
    Return "OK"

    Catch e As Exception
    Return e.Message
    End Try
    End Function
     
    Saddergoat, Sep 5, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. M. Duijkers
    Replies:
    2
    Views:
    480
    Joe Smith
    Dec 12, 2004
  2. Replies:
    6
    Views:
    430
  3. Jimmy Jazz

    Recieve Post, New Session Won't Stick, Cookielss

    Jimmy Jazz, Sep 2, 2005, in forum: ASP .Net Security
    Replies:
    0
    Views:
    149
    Jimmy Jazz
    Sep 2, 2005
  4. Julia
    Replies:
    7
    Views:
    240
    Bill Puetz
    Oct 22, 2004
  5. Replies:
    1
    Views:
    159
    James Britt
    Jun 23, 2005
Loading...

Share This Page