Recieve a file via HTTP POST to a webservice

S

Saddergoat

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top