Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8438071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:36:25+00:00 2026-06-10T07:36:25+00:00

There’s an image gallery site, and the user can manipulate the images via javascript

  • 0

There’s an image gallery site, and the user can manipulate the images via javascript and HTML5 canvas. Is it possible to send back the manipulated image to the server for storing with PHP?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:36:26+00:00Added an answer on June 10, 2026 at 7:36 am

    HERE you can find a complete article on the subject. But here’s the short version and source codes:

    First you need to convert the canvas binary data as a base 64 encoded string to send it to server:

    var image = canvas.toDataURL("image/png");
    

    Send this with an ajax call:

    var ajax = new XMLHttpRequest();
    ajax.open("POST",'save.php', false);
    ajax.setRequestHeader('Content-Type', 'application/upload');
    ajax.send(image);
    

    Finally the PHP script save.php looks like this:

    <?php
    if (isset($GLOBALS["HTTP_RAW_POST_DATA"]))
    {
        // Get the data
        $imageData=$GLOBALS['HTTP_RAW_POST_DATA'];
    
        // Remove the headers (data:,) part. 
        // A real application should use them according to needs such as to check image type
        $filteredData=substr($imageData, strpos($imageData, ",")+1);
    
        // Need to decode before saving since the data we received is already base64 encoded
        $unencodedData=base64_decode($filteredData);
    
        //echo "unencodedData".$unencodedData;
    
        // Save file.  This example uses a hard coded filename for testing,
        // but a real application can specify filename in POST variable
        $fp = fopen( 'test.png', 'wb' );
        fwrite( $fp, $unencodedData);
        fclose( $fp );
    }
    ?>
    

    The PHP script parses the raw post data, converts from base 64 to binary, and saves to a file. For more information on Base 64 check out THIS Wikipedia article.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are many string matching algorithms can be used to find a pattern (string)
There is some contradiction in the api documentation: on one location: https://developer.foursquare.com/docs/responses/user on another
There's any chance to observe for order elements of array via KVO?
There are two popular closure styles in javascript. The first I call anonymous constructor
There are a few ways to get class-like behavior in javascript, the most common
there's a php scripts which create multiple <p>text</p> elements due to user's query. I'd
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
There's a lot of reading on self referencing problems, but I can't seem to
There is a User Table. Id Name Surname Address OID 1 n1 s1 a1
There is a legacy site that I'm working on, and I need to swap

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.