upload binary (multipart/form-data)

Hey everyone!

I'm trying to upload an image with an string to my web site through php

the code works fine in simulator, I can upload my image BUT I can't open image after uploaded and in device I can't upload I get an error:

"Lua Runtime Error: lua+pcall failed with status: 2, error message is: assertion failed!"

someone can please help me?

The code for this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
local MultipartFormData = require("class_MultipartFormData")
 
local multipart = MultipartFormData.new()
multipart:addHeader("Customer-Header", "Custom Header Value")
multipart:addField("myFieldName","myFieldValue")
multipart:addField("banana","yellow")
multipart:addFile("myfile", system.pathForFile( "myfile.jpg", system.DocumentsDirectory ), "image/jpeg", "myfile.jpg")
 
local params = {}
params.body = multipart:getBody() -- Must call getBody() first!
params.headers = multipart:getHeaders() -- Headers not valid until getBody() is called.
 
local function networkListener( event )
        if ( event.isError ) then
                print( "Network error!")
        else
                print ( "RESPONSE: " .. event.response )
        end
end
 
network.request( "http://www.example.com", "POST", networkListener, params)

are you sure you add permission to access internet in your config file ???

I need to in iPad/iPhone?

i cant understand what you mean in iphone is it work in android devices ?

I only tested in iPad

???

Dhennrich, if you can post a sample project download someone may be able to further assist you. (Or plug and play.)

mhantash - I have already asked you once not to hijack threads. Copying and pasting the same thing into multiple threads where it is NOT relevant at all is going to get you in trouble - so don't do it. http://developer.anscamobile.com/forum/2011/05/05/forum-rules-and-guidelines

Peach :)

views:2770 update:2011/12/1 20:56:45
corona forums © 2003-2011