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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:30:58+00:00 2026-06-13T23:30:58+00:00

I edit a png image put some text on it and display is as

  • 0

I edit a png image put some text on it and display is as

<?php    
ob_start();
imagepng($img, NULL);
$rawImageBytes = ob_get_clean();
imagedestroy($img);
echo "<img id='ca_image' src='data:image/png;base64," . base64_encode($rawImageBytes)     . "' />";

?>
<a href="#" onclick="return download();">Download</a>
<script>
function download(){
var img =document.getElementById("ca_image").src;
var url = img.replace(/^data:image\/[^;]/, 'data:application/octet-stream');
location.href = url;
</script>

as i change the content type of file,browser automatically pop up window to download but downloaded file type is PART . i want to download base_64 as png file.
is this possible by this approach?
is this the right approach to save file as png?
if not Please suggest the right way to solve my problem.

  • 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-13T23:30:59+00:00Added an answer on June 13, 2026 at 11:30 pm

    i solve it as

     <input name="string" type="hidden" value="<?php echo base64_encode($rawImageBytes) ?>"/> 
    

    and in php

    $base64strImg=$_REQUEST['string']; 
     header('Content-Disposition: attachment;filename="test.png"');
    header('Content-Type: application/force-download'); 
    echo base64_decode($base64strImg);
    

    can it create some problem? as have not check the string.

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

Sidebar

Related Questions

Hi i have this starnge behavoir... <%= link_to image_tag(image.png), brain_path(1), :method => put %>
EDIT: I was an idiot. I simply had an image that was vertically long,
EDIT: iam using ajax to load text in my content that is why onload
** EDIT November 17th ** Hi again, I wanted to show some code you
I have an article in which I use PHP code inside the text editor
So following Apple's DocInteraction Sample here I put a static NSString to define some
I created a directory MyDirectory inside a bundle myBundle. I then put an image
I've an image of 32x32, which I have put in drawable folder and the
I am trying to get assert_select to work on some raw text. Below is
I have some RGBA data in Python 3 and I want to display the

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.