I created a web service using C# to allow file upload
the service is working perfectly tested with Fiddler4 tool https://www.telerik.com/download/fiddler
In Corona This is the code which is working! as print commands show … but file is not being copied to upload folder
local function uploadListener( event )
if ( event.isError ) then
print( “Network Error.” )
else
if ( event.phase == “began” ) then
print( “Upload started” )
elseif ( event.phase == “progress” ) then
print( "Uploading… bytes transferred ", event.bytesTransferred )
elseif ( event.phase == “ended” ) then
print( “Upload ended…” )
print( “Status:”, event.status )
print( “Response:”, event.response )
end
end
end
local url ="http://localhost/corona/fileupload"
local method = “POST”
local params = {
timeout = 60,
progress = true,
bodyType = “binary”
}
local filename = “image.jpg”
local baseDirectory = system.ResourceDirectory
local contentType = “multipart/form-data”–also tried image/jpeg also tried image/jpg
local headers = {}
– headers[“Content-Type”]=“multipart/form-data”–also tried image/jpeg also tried image/jpg — no need for this line it is defined as contentType
params.headers = headers
network.upload( url , method, uploadListener, params, filename, baseDirectory, contentType )
i’m not really sure what the problem is, i tried to run .NET in debug mode, when using fiddler to upload a file, in .NET Request.Files.Count gives one, but when running this code from Corona the returned value is 0
attached is the print command output