Dynamic Image request troubles (AJAX, Dropbox...!?)

Get help using Construct 2

Post » Thu Aug 21, 2014 11:16 am

It is a very long string I do know, but that seems rather excessive. I have an upload picture function in my facebook plugin that uses the png string to upload to the users profile. I doesn't slow me down at all. I'm not sure are you possibly calling the snapshot action multiple times?
www.h1k3.tech

We are here for you!
B
87
S
22
G
16
Posts: 715
Reputation: 16,785

Post » Thu Aug 21, 2014 1:49 pm

Nope, doesn't seem to be the case. In this instance, I'm not snapshotting the canvas in any case. I'm using Pode's ExtractImage plugin to convert the image to a base64 string, and trying to send this to the db.

Live (not working) test here: http://dev.angelserver.in/construct2_test/db_test/

Inspect with Firebug or something to track what's going on.

Event sheet for new test below:

Image

So, with this I get a rare 414 error: URI too long! Haven't ever actually seen one of these before. I'm not sure how to handle this. You'll be able to see the length of the base64 string in the Firebug console.
B
7
S
1
Posts: 61
Reputation: 588

Post » Thu Aug 21, 2014 2:40 pm

Update: used a POST request instead, and Firebug comes back with a success, however the database is not updated.

Changing the default value of the base64 variable to '123' does update the database, which confirms that my PHP file is working.

It's unclear where the problem is occuring. Perhaps something to do with my data type, or simply the exceedingly long string? (768692 characters in the version generated on the server).
B
7
S
1
Posts: 61
Reputation: 588

Post » Thu Aug 21, 2014 2:45 pm

You can't request images with the AJAX object, because it only returns text data.

Instead just use the Sprite object's 'Load image from URL' to load it directly, without using AJAX at all.
Scirra Founder
B
397
S
236
G
88
Posts: 24,420
Reputation: 194,549

Post » Thu Aug 21, 2014 2:47 pm

Ah, well that's the first mystery cleared up. Thank you, @Ashley .
B
7
S
1
Posts: 61
Reputation: 588

Post » Thu Aug 21, 2014 2:58 pm

New update: tried to convert the base64 string to binary and store it this way, but still no joy! Firebug is loving it; still thinks that it is 200 OK!

Code: Select all
//Just FYI - code used to convert base64 to binary
$importedData = $_POST['BASE64'];
$str = $importedData;
base64_decode($str);
$qz = "INSERT INTO `user_images`(`base64_string`) VALUES (".$str.")" ;


Edit: Update update: copying and pasting the base64 string manually into the database works! So it isn't our database, it isn't my PHP file, and Firebug still seems to think it is all working okay. :lol: :?
B
7
S
1
Posts: 61
Reputation: 588

Post » Mon Sep 01, 2014 11:44 am

Just an update; I am testing a new approach using the Dropbox plugin by septeven. Still having issues however... Really starting to hate this application I'm building! One brick wall after another that I'm banging my head against!

So. New approach.

Live here: http://dev.angelserver.in/IMG_Sharing/

Image

This is what happens:

- On hitting the 'test' button, a snapshot is taken of the layout.
- To prove that a snapshot has been taken, this is loaded into an empty sprite.
- This image is then created on Dropbox, using the data from the CanvasSnapshot:

Image

- Then, to prove that the file has successfully been created in Dropbox, we load the created file into another empty Sprite.

...So. The snapshot has been taken, as this is successfully loaded into the first empty sprite. Check the Dropbox? Yes, the file has been created. Good.

But the resultant image is not loaded into the second empty sprite, suggesting that a problem has occurred at the upload stage. Check the Dropbox again, open the file:

Image

And sure enough, upon downloading the file, it appears to be corrupt. Something appears to be going wrong at the saving/upload stage, but I'm not sure what. There *is* data within "CanvasSnapshot" to be uploaded, however it does not seem to be transferring to the created file on Dropbox.

Of course, the sharing functions then also do not contain images, because they reference the created file on Dropbox which contains a faulty file.

Even stranger is that upon clicking the "Test" button again, an image IS loaded into the second empty sprite - but not of the current Snapshot. I fail to understand where it is getting this data from - it appears to be the last CanvasSnapshot - is it loading the previously saved file?

Not sure what's going on, it's all a bit of a mess.
B
7
S
1
Posts: 61
Reputation: 588

Previous

Return to How do I....?

Who is online

Users browsing this forum: KTML5 and 32 guests