How do I Use AJAX to upload SnapShot to server.

Get help using Construct 2

Post » Wed Jan 07, 2015 7:54 pm

I want to upload to a server a picture taken from the mobile camera.

I'm trying an ajax request to php but for some reason, the snapshot won't arrive on the server, any other parameter that i use gets there ok, but the snapshot comes out blank.

"http://www.shifty.com.br/tran/postPicture.php?pic=" & UserMedia.SnapshotURL

above is the string i'm using for the request.

Is this the way to do it?

Thanks
B
7
S
1
Posts: 27
Reputation: 479

Post » Thu Jan 08, 2015 1:20 am

I'm not sure what environment you are running the project, so my help can be limited. I also do not know what your php code is.

If this is a phone app, which I am assuming it to be. I believe SnapshotURL gives the location of the snapshot on the phone's file system, e.g. /internalstorage/yourapp/snapshots or whatever. Then if your php script gets this data what is it to do? I doesn't actually have the file you're telling it, only its path on the phone it was taken on. I do not know if Construct has a proper upload feature, but what you could possibly do it retrieve the data from the snapshot, the actual 1's and 0's in a reconstructible format, an image raster. Then you can get this data and post it to your php page for the php to then reconstruct the data from the raster and display the image.

I'm no expert in this area so this could all be completely wrong, but I hope it helps.
Nothing goes unanswered!
B
24
S
5
G
1
Posts: 434
Reputation: 3,446

Post » Thu Jan 08, 2015 4:53 am

UserMedia.SnapshotURL is actually an image encoded as a data URI, so he should be able to upload it to any php script using a post. Might we see your events ? It might be easier to help.
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Thu Jan 08, 2015 10:56 am

I found a similar post to mine, apparently the encoded image is too large a string to be passed as a POST to PHP. Someone had the same issue as me and got around it using a dropbox plugin. Its too much of a hack for what I need to do. I'm going native for this one, thanks guys...
B
7
S
1
Posts: 27
Reputation: 479

Post » Thu Jan 08, 2015 2:24 pm

Have you tried tweaking the settings of your server to allow for bigger http request ?
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Fri Jan 09, 2015 8:20 am

Magistross wrote:Have you tried tweaking the settings of your server to allow for bigger http request ?


Unfortunately it's shared hosting... I don't have access..

It's a very simple app, I decided to make it in Flash Builder.

thanks
B
7
S
1
Posts: 27
Reputation: 479


Return to How do I....?

Who is online

Users browsing this forum: ultrafop and 16 guests