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 two layers (Image control with PNG bitmap) inside Grid (or Canvas): one
There's example: http://www.jquery4u.com/jquery-functions/setinterval-example/#.UHW6_IYY18E Hover over RSS feedburner image - it will shake. In my
There are times when the document the user is looking for is not present
There's a thrird party app that needs to get information via custom http headers,
There can only be one IDENTITY column per table Why is it so? Take
There's no Sort() function for IList . Can someoene help me with this? I
There are two tables: aspnet_users and aspnet_membership. Can anyone elaborate on the reasons why
There was a thread on this in comp.lang.javascript recently where victory was announced but
There are a few ways to do this in javascript. Foremost and most readable
there's a php scripts which create multiple <p>text</p> elements due to user's query. I'd

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.