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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:01:27+00:00 2026-05-24T08:01:27+00:00

My goal is to simply echo $_POST[‘imageVar’]; back with content headers as a quick

  • 0

My goal is to simply echo $_POST[‘imageVar’]; back with content headers as a quick and dirty means to “export” an image from a flash application. I saw an example of this as follows, but it does not work with my php version/config:

if (isset($GLOBALS["HTTP_RAW_POST_DATA"]))
{
    // get bytearray
    $jpg = $GLOBALS["HTTP_RAW_POST_DATA"];

    // add headers for download dialog-box
    header('Content-Type: image/jpeg');
    header("Content-Disposition: attachment; filename=".$_GET['name']);
    echo $jpg;
}

So as a work around I created a script that saves the image to the server, reads the image and echos it back, then deletes the image. I don’t like this approach as I need to have a directory that is writable by the apache user (im on a shared server). Is there a way to accomplish what I am doing here without hte need to use the temp file?

<?
$fileName = basename( $_FILES['uploadedfile']['name']);
$tempFile = "uploads/" . $fileName;
$fileSize = $HTTP_POST_FILES['uploadedfile']['size'];
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $tempFile)) {
        $fh = fopen($tempFile, 'r');
        $fileContents = fread($fh, $fileSize);


        header('Content-Type: image/jpeg');
        header("Content-Disposition: attachment; filename=$fileName");
        echo $fileContents;

        fclose($fh);
        unlink($tempFile);
} else {
        echo "upload fail";
}

?>

Any input or ideas greatly appreciated! Thanks for looking

  • 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-05-24T08:01:28+00:00Added an answer on May 24, 2026 at 8:01 am

    You can just use:

    header('Content-Type: image/jpeg');
    header("Content-Disposition: attachment; filename=$fileName")
    readfile($_FILES['uploadedfile']['tmp_name']);
    

    No need to move it if you’re not going to keep it.

    On a side note, regarding the first solution you were looking at, does an echo file_get_contents('php://input'); not work?

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

Sidebar

Related Questions

Is there a Maven phase or goal to simply execute the main method of
My goal is to simply use a pop-up box to ask the user for
My goal is to simply update the lastmod node in a simple sitemap xml
My goal is to simply have the cursor swap to be a hand (pointer)
My goal is simply to show a language-specific errormessage for a Required-Annotation: [Required(ErrorMessageResourceName =
My goal is to recognize simple gestures from accelerometers mounted on a sun spot.
My goal here is to create a very simple template language. At the moment,
My goal is to deploy a simple rails application on a windows server using
I have a fairly simple addition to the HTTP standard. An ambitious goal I
I'm making a very simple 2D RPG in Java. My goal is to do

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.