title: iOS Safari automatically save downloaded image
body: <p>I am working on a website where a png image is downloaded from a php script. By sending headers we force the image to download in most browsers.</p>
  
  <p>In iOS the image opens in the browser tab taking the user away from the UI and forcing them to manually long click and choose "Save Image" to save the downloaded image in their Camera Roll.</p>
  
  <p>The download script sends headers like these:</p>
  
  <pre><code>&lt;?php
  $fileName="image.png";
  $filePath="/somepath/".$fileName;
  
  header('Content-Description: File Transfer');
  header('Content-Type: application/octet-stream');
  header('Content-Disposition: attachment; filename="'.$fileName.'"');
  header('Content-length: ' . filesize($filePath));
  
  readfile($filePath);
  exit;
  </code></pre>
  
  <p>I am wondering if there are any headers I can send that would cause mobile safari on iOS to send the image straight to the camera roll without extra user actions or if there is a JS api that would allow pushing of images into the Camera Roll.</p>
  
  <p>I realise this may not be possible as ios apps to not access the filesystem directly the way other platforms allow and have looked at similar questions:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/q/8620039">HTTP &quot;Content-Disposition: attachment&quot; and downloading files on iOS web browser</a></li>
  <li><a href="https://stackoverflow.com/q/16578453">Can any HTTP headers force iOS to download video (rather than streaming it)</a></li>
  </ul>
  
  <p>I am just hoping there might be something specific to images to cause safari to send an image to Photos or the Camera Roll rather than viewing it in Safari.</p>