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 8317063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:30:09+00:00 2026-06-08T21:30:09+00:00

I have used HTML 5 canvas for drawing something on it using javascript after

  • 0

I have used HTML 5 canvas for drawing something on it using javascript after i have done with drawing i have to save that canvas in hard disk. I can obtain the image src by using the following method:

var img = canvas.toDataURL();

after this the img variable contains something like the following value

data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAABkCAYAAABwx8J9AAAP/UlEQVR4Xu2dX4wV1R3HZwSCkbWIRpA+UMqfatwArqyKVSMUbENbGx8KafvQxDaRYKMvbdPyxPWlaNK+1FSDD/WptsEXUkWaytY1aK2y65YlS1SQrDR2Xa2KZTEQwNvvb51LLtvdvXPnnjt/znxucjJ3984553c+5zfznd+cM2fCgA8EIAABCEAAAoUnEB…………

I can use this image src like

<img id=myimage" src=img />

and the image gets displayed perfectly in a web browser.

What i want to do is save this image on the hard disk. Is there any way to save it with PHP or javascript.

Any help will be appreciated.

  • 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-08T21:30:10+00:00Added an answer on June 8, 2026 at 9:30 pm

    For PHP >=5.2.0, you can use the data:// stream wrapper:

    file_put_contents("file.png",file_get_contents("data://".$var_containing_the_data_uri));
    

    where $var_containing_the_data_uri should be replaced by the variable containing the data URI, for example $_POST['image'].

    You could send the data using AJAX post. If you use GET method beware of the URL length limit.

    Or if you want to let the clients download/save the image, just create an <img> element with the data URI src and tell the client to Right-click and save it. You can also refer to the link that @Kode-Plus stated.

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

Sidebar

Related Questions

I have used both, and I conclude that I can read html data from
I have a component that used to work (Without setting HTML tags to the
I have n number of select elements in an html page that are used
I have used opera unite for deploying a static html/css/javascript website just for fun.
I have used to have @using (Html.BeginForm()) { <input type=submit formaction=/home /> } And
I am mailing a HTML page as attachment. I have used <div style=page-break-after:always;> </div>
I have used PHP array for HTML select, then I put my codes in
I have used fieldset tag in HTML page, whereby i need some text to
see jsbin I have to make my html table vertically scrollable. I have used
I have the following HTML: <section id=sidebar class=grid_3> <section id=content class=grid_9> I used jQuery

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.