I’m trying to develop an app that is able to open camera with button ( does work yay ).7
So I took Rob’s Php script ( https://www.dropbox.com/s/yc3z9a9xgf5kkim/upload.php ).
Problem No. 1:
So if it opens camera and I press leave button, the event thinks I have taken a photo anyway.
Problem No. 2:
If I press upload, the client start to upload! ( yay again … ).
But after some seconds my client gets the error messag 500 from the php.
So any hint what can I do better?
local background = createImage( "build/media/background.png", display.contentWidth, display.contentHeight ) background:toBack(); local info = createText( "Bitte haben Sie einen Moment Geduld!",display.contentWidth / 2, display.contentHeight / 1.05, native.systemFontBold, 38 ) info:toFront(); local trigger = createImage( "build/media/camera.png", 256, 256 ) trigger:toFront(); local isPhoto = false Runtime:addEventListener( "system", function( event ) if ( event.type == "applicationStart" ) then info.text = "Berühren Sie die Kamera, um eine Aufnahme zu machen." end end ) trigger:addEventListener( "tap", function( event ) if ( isPhoto == false ) then media.capturePhoto( { listener = onPhoto, destination = { baseDir = system.TemporaryDirectory, filename = "capture.jpg", type = "image" } } ) else -- paramteres from rob -- local params = { timeout = 60, progress = true, bodyType = "binary" } local headers = {} headers.filename = filename params.headers = headers -- \< - \> -- network.upload( "http://www.m7-studios.de/labor/razor.php", "POST", onNetwork, params, "capture.jpg", system.TemporaryDirectory, "image/jpeg" ) trigger.isVisible = false end media.playSound( "build/media/tap.mp3" ) return true end ) function onPhoto( event ) if ( event.completed == true ) then info.text = "Berühren Sie die Kamera nun, um die Aufnahme hochzuladen." isPhoto = true elseif ( event.completed == false ) then info.text = "Berühren Sie die Kamera, um eine Aufnahme zu machen." isPhoto = false end end function onNetwork( event ) if ( event.isError ) then info.text = "Der Vorgang wurde abgebrochen!" trigger.isVisible = true isPhoto = false else if ( event.phase == "began" ) then info.text = "Die Verbindung wird hergetellt..." elseif ( event.phase == "progress" ) then info.text = "Daten werden übertragen... "..event.bytesTransferred.." Bytes" elseif ( event.phase == "ended" ) then info.text = "Status: "..event.status..", Antwort: "..event.response.."." trigger.isVisible = true isPhoto = false end end end