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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:40:03+00:00 2026-06-09T11:40:03+00:00

I am attempting to read an image file, as a base64 encoded string and

  • 0

I am attempting to read an image file, as a base64 encoded string and output a data string when the connection uses HTTPS/SSL, and otherwise put out the URL in the IMG src attribute if it is only on HTTP. Here is my current code, however it does not work.

<?php 
function base64_encode_image($filename, $filetype) {
    if (($_SERVER["HTTPS"] == "on") && $filename) {
        $file = "/home/content/61/9295861/html/resource/image$filename";
        $imgbinary = fread(fopen($file, "r"), filesize($file));
        return "data:image/$filetype;base64," . base64_encode($imgbinary);
    } else {
        return $filename;
    }
}
?>
<img src="<?php echo base64_encode_image('/resource/image/logo-96x72.png', 'png'); ?>" width="96" height="72" />

It outputs:

<img src="<br />
<b>Warning</b>:  fopen(/home/content/61/9295861/html/resource/image/resource/image/logo-96x72.png) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory in <b>/home/content/61/9295861/html/theme/latest/index.php</b> on line <b>5</b><br />
<br />
<b>Warning</b>:  filesize() [<a href='function.filesize'>function.filesize</a>]: stat failed for /home/content/61/9295861/html/resource/image/resource/image/logo-96x72.png in <b>/home/content/61/9295861/html/theme/latest/index.php</b> on line <b>5</b><br />
<br />
<b>Warning</b>:  fread() expects parameter 1 to be resource, boolean given in <b>/home/content/61/9295861/html/theme/latest/index.php</b> on line <b>5</b><br />
data:image/png;base64," width="96" height="72" />
  • 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-09T11:40:04+00:00Added an answer on June 9, 2026 at 11:40 am

    You have added the /image/resource directory twice to your URL which is resulting in a file not found error.

    $file = "/home/content/61/9295861/html/resource/image$filename";
    $filename = "/resource/image/logo-96x72.png"
    

    So your File URL is /home/content/61/9295861/html/resource/image/resource/image/logo-96x72.png

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

Sidebar

Related Questions

I am attempting to insert an image into a rich text file. I have
I am attempting to read audio data via AudioQueue. When I do so, I
I am currently attempting to read in Hex values from a text file. There
I have data stored in a SQL database that I'm attempting to read into
i'm attempting to maximize the scale of an image so that it uses as
While attempting to read data from memory into an enum via the following code,
I'm attempting to read the file.txt into java line by line and then when
I am attempting to read in from a txt file strings that are very
Well, I am attempting to read a text file that looks like this: FTFFFTTFFTFT
I'm attempting to read the content of a XML file, using XmlTextReader in C#,

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.