Having trouble uploading file from phone to server

Hello,

I need to upload a file and it’s not working. I know the file is there and exists so that’s not the problem. I have tried it two ways.

First, this code for a html page works for uploading. I tested it.

\<form method="post" action="http://xx.xx.xx.xx:8080/webpage.htm?dd=325443" name="submit" enctype="multipart/form-data"\> \<input type="file" name="fileField"\>\<br /\>\<br /\> \<input type="submit" name="submit" value="Submit"\> \</form\>

So in Corona I tried this:

URL3 = "http://" .. storyboard.IP7 .. ":" .. storyboard.Port7 .. "/" .. storyboard.WebFile7 .. ".htm" local File2 = "testfile.3gp" local path = system.pathForFile( "testfile.3gp", system.DocumentsDirectory ) response\_body = {} local body, code, headers = http.request{ url = URL3, method = "POST", headers = { ["Content-Type"] = "multipart/form-data" }, source = path }

I tried with the network.upload and not sure if i had it right. Can someone show me how to upload a single file? I have read many postings and tried them and nothing yet.

Thanks!

[lua]

network.upload(
URL3,
“POST”,
networkListener,
“testfile.3gp”,
system.DocumentsDirectory,
“audio/3gp”
)

[/lua]

This did not uplaod for me. I am uploading to an http server and the code below works fine for it. But I cannot get it to work from this app. Why am I having so many problems with it? on the networklistener I do not get any errors or any type of reply either.

\<form method="post" action="http://xx.xx.xx.xx:8080/webpage.htm?dd=325443" name="submit" enctype="multipart/form-data"\> \<input type="file" name="fileField"\>\<br /\>\<br /\> \<input type="submit" name="submit" value="Submit"\> \</form\>

I think it would be best to use the http.request to simulate what I did before on a web page. Does anyone have the code to show how to do this for a single file?

Does anyone know how to do the same type of upload in Corona that I did using the web file upload? I still cannot get the network.upload to work but yet I can with the html posted.

Thanks!

\<form method="post" action="http://xx.xx.xx.xx:8080/webpage.htm?dd=325443" name="submit" enctype="multipart/form-data"\> \<input type="file" name="fileField"\>\<br /\>\<br /\> \<input type="submit" name="submit" value="Submit"\> \</form\>

I finally got it! I used the following:

http://developer.coronalabs.com/code/how-upload-image-server-multipartform-data

Where I was uploading to had to have it as a multipart form data or it owuld not recognize it.

Warren

[lua]

network.upload(
URL3,
“POST”,
networkListener,
“testfile.3gp”,
system.DocumentsDirectory,
“audio/3gp”
)

[/lua]

This did not uplaod for me. I am uploading to an http server and the code below works fine for it. But I cannot get it to work from this app. Why am I having so many problems with it? on the networklistener I do not get any errors or any type of reply either.

\<form method="post" action="http://xx.xx.xx.xx:8080/webpage.htm?dd=325443" name="submit" enctype="multipart/form-data"\> \<input type="file" name="fileField"\>\<br /\>\<br /\> \<input type="submit" name="submit" value="Submit"\> \</form\>

I think it would be best to use the http.request to simulate what I did before on a web page. Does anyone have the code to show how to do this for a single file?

Does anyone know how to do the same type of upload in Corona that I did using the web file upload? I still cannot get the network.upload to work but yet I can with the html posted.

Thanks!

\<form method="post" action="http://xx.xx.xx.xx:8080/webpage.htm?dd=325443" name="submit" enctype="multipart/form-data"\> \<input type="file" name="fileField"\>\<br /\>\<br /\> \<input type="submit" name="submit" value="Submit"\> \</form\>

I finally got it! I used the following:

http://developer.coronalabs.com/code/how-upload-image-server-multipartform-data

Where I was uploading to had to have it as a multipart form data or it owuld not recognize it.

Warren