Post Data Url returns a 0x0 png

0 favourites
  • 2 posts
From the Asset Store
We present to you “Post Apocalyptic Trailer” – our newest hard hitting, bass rumbling designed movie trailer collection.
  • I have a code that gets data(png,jpg and stuff) and save it as a file.

    	// requires php5
    	header('Access-Control-Allow-Origin: *');
    	define('UPLOAD_DIR', 'static/images/');
    	$img = $_POST['img'];
    	$img = str_replace('data:image/png;base64,', '', $img);
    	$img = str_replace(' ', '+', $img);
    	$data = base64_decode($img);
    	$file = UPLOAD_DIR . uniqid() . '.png';
    	$success = file_put_contents($file, $data);
    	print $success ? $file : 'Unable to save the file.';
    The host is<pathhere>  the path here is removed as it can be used to post stuff if gotten hold off.
    raw:     "type='base64'&image=" & URLEncode(RegexReplace(CanvasSnapshot, "data:image/png;base64,", "", ""))
    but everytime it gets posted it makes a 0x0 png file. 
    So what am I doing wrong?
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Your Data field doesn't represent valid variable for Post, it just returns nothing, look your php script:

    $img = $_POST['img'];

    It should be

    $img = $_POST['image'];

    You don't need to add useless functions because your PHP script already comes same functions as replace function.

    Data field, should be:


    image variable represents post data.

    It's simple, that's all.

    If you aren't sure, you might consider to get this template. ... -image-116

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)