Upload Image to Webserver (Classic ASP)

vb1992

Well-Known Member
Licensed User
Longtime User
Here is the code and example to upload an image
from your android phone to a windows based web server
with a classic asp script / vbscript

(instead of php)

Most examples on here are all PHP based server examples


This should also work with the ACL
Advanced Camera Library
to upload photos
 

Attachments

  • ClassicAsp.zip
    12.6 KB · Views: 2,195
Last edited:

Silentsea

Member
Licensed User
Longtime User
Hi,

it works fine on my tab, with pics about 1Mb but on my note I tested it with pics round about 2.5 Mb without sucess. Where is the limiter?
 
Upvote 0

Silentsea

Member
Licensed User
Longtime User
I found it, were the setting on the webserver (e.g. timeout). Sry but i waited for an exception :/
 
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User
Upvote 0

kent

Member
Licensed User
Longtime User
I have been using the classic asp code for some time and it works perfect.

However, I like to translate it to asp.net vb. Nevertheless, I´m unsure to how to get it to work.

I know it not a direct Androd4basic question, but I believe this is the best forum.

The android code is unchanged:
Dim req AsHttpRequest
Dim size AsLong
size = File.size(File.DirRootExternal, fil)
InputStream1 = File.OpenInput(File.DirRootExternal, fil)
req.InitializePost("http://XXXXXXXX/uploadform_lyd.aspx?hvad=" & hvad2 & "&tlf=" & tlf_id, InputStream1, size)
HttpClient1.Execute(req, 1)

The old classic asp code was:
a=Request.TotalBytes
if a >1 then
b=Request.BinaryRead(a)
set BinaryStream = CreateObject("ADODB.Stream")
BinaryStream.Type = 1 '// binary data
BinaryStream.Open
BinaryStream.Write b
BinaryStream.SaveToFile hvor & strFileName, 2 '// save to disk
set BinaryStream = nothing
end if

my draft asp.net vb code:
Dim bytes AsInteger
bytes = Request.TotalBytes
If bytes > 1 Then

Dim byteData() AsByte
byteData = Request.BinaryRead(bytes)
Dim oFileStream As System.IO.FileStream
oFileStream = New System.IO.FileStream(hvor & strFileName, System.IO.FileMode.Create)
oFileStream.Write(byteData, 0, byteData.Length)
oFileStream.Close()
end if

I am not sure how to debug it, but my HttpClient1_ResponseError "Reason" returns: Internal Server Error

What am I doing wrong ?

Is there at better/easier way ?

Does anyone have a working example ?

Thanks in advance.
Kent
 
Upvote 0

kent

Member
Licensed User
Longtime User
Thank for you reply – I will try to implement your web service "save function"

My is not a web service just a xxx.Aspx file.

If I access the xxx.aspx file via a browser, I do not get any error but when there is not stream data either.

And if I uncomment all the code in aaa.aspx file but a response.write ("test") and access it from basic4androd the HttpClient1_ResponseError returns
Reason=Internal Server Error
Response=anywheresoftware.b4a.http.HttpClientWrapper$HttpResponeWrapper@405b6fe0

So maybe it has nothing to do with my code, but something with the access or authentication (it is a newly installed iis.)

I just don´t know what !
 
Upvote 0
Top