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
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