title: PHP force download .png file
body: <p>Hello and thank you for your time.</p>
  
  <p>I am trying to use the following code to force a download of a .png image that is created from a Unity application I developed onto the users computer.</p>
  
  <pre><code>    &lt;?php
      //get the input information
      $stringName = $_POST["stringName"];//name
      $imageString = $_POST["imageString"];//image in string form
  
      $dataX = base64_decode($imageString);//make the string into the image
      file_put_contents($stringName, $dataX);//save the image on the server
  //everything thing above this line works within Unity
  
      $fileSize = filesize($stringName);//get the file size
  
      //bunch of headers, comments next to the ones I have an idea about
      header("Pragma: public");
      header("Expires: 0");
      header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
      header("Cache-Control: private",false);
      header("Content-Type: imagepng");//gives content type
      header("Content-Length: ".$fileSize);//file size
      header("Content-Disposition: attachment; filename=".$stringName);//download file path
      header("Content-Transfer-Encoding: binary");
      ob_clean();
      flush();
      readfile( $stringName );
  ?&gt;
  </code></pre>
  
  <p>I have this but it doesn't pop up with a download confirmation box, or do anything with the provided image. </p>
  
  <p>When running my program in a browser I get ether one of two errors when calling the above script. Since I am hosting the application from dropbox I get "cannot send from https to http", and when I change the address for the php file to https it times out. </p>
  
  <p>So first, is there a way to get the https, and http to allow communication between the two, I would prefer NOT having to host my unity project on the ftp server as I have a few projects set up the same way. Second, will that PHP script work correctly, and if so is there some stuff I can cut out? </p>