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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:45:04+00:00 2026-06-01T06:45:04+00:00

I run PHP 5.2 on Ubuntu with Apache 2. When I want to serve

  • 0

I run PHP 5.2 on Ubuntu with Apache 2.

When I want to serve a PNG file from PHP file which is hardcoded (using $imgname), I can succeed. However if I change the $imgname to $imgdbname, the browser fails and says it is not a valid PNG file.

$imgname = "cachepics/c3s9taopkp.png";
$imgdbname = readfromdb();

header("Content-type: image/png");
print file_get_contents($imgname);

However if I comment the header("Content-type: image/png"); line, browser shows the all PNG garbage text in both cases. Therefore, I am sure the PHP instance is able to reach that file by reading the path from DB.

The ouput of

print "-".$imgname."-".$imgdbname."-";

seems exactly the same.

-cachepics/c3s9taopkp.png-cachepics/c3s9taopkp.png-

I will go crazy and don’t know why the db version does not work.

  • 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-01T06:45:05+00:00Added an answer on June 1, 2026 at 6:45 am

    Perhaps the problem is that readfromdb have errors and generate warnings, printing these warning to STDIO, adding garbage to the resulting image, or aborting any later header (like content-type).
    You could probably check the server error log for that (any warning of the style ‘header can’t be added, because already printed in file..’), or test if both resulting files are the same size.

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

Sidebar

Related Questions

I'm running a Ubuntu Server with Apache. PHP and HTML both run correctly using
I using a new server (Rackspace, Ubuntu 10.04) trying to run a php file
I'm trying to run my php App from Ubuntu Server 11.10. This App works
I have a PHP-script originally developed on Ubuntu, which now has to run on
Using Apache 2.2 and PHP 5, what's the best way to run PHP without
Can I run a PHP CGI script as a background process using exec() ?
I've been currently using PHP on Apache (on Ubuntu) to do dynamic server-side stuff,
I've been building PHP tools with a MySQL backend. Using multi-curl I can run
I'm attempting to run the following command in PHP (on Ubuntu): <?php if (exec(/home/johnboy/ffmpeg/ffmpeg
I am writing a pre-commit hook. I want to run php -l against all

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.