title: How do I fix Firefox trying to "Save image as" .htm?
body: <p>We've recently implemented Amazon S3 in our site which led us to change the way we handled images. We used to call a controller /fotos.php that would read the file from disk, record some statistics, set headers and return the contents of the file as image/jpeg.</p>
  
  <p>All went OK until S3. Fotos.php now does a 302 redirect to the resource in Amazon and all is nice and working, but you can't save a image in Firefox because it sets its file type as .htm. I found this discussion on the matter, and it seems like a bug in Firefox:</p>
  
  <p><a href="https://bugs.launchpad.net/ubuntu/+source/firefox-3.0/+bug/207670" rel="nofollow noreferrer">https://bugs.launchpad.net/ubuntu/+source/firefox-3.0/+bug/207670</a></p>
  
  <p>Here is a URL exhibiting the problem (try to save the big image):</p>
  
  <p><a href="http://www.viajeros.com/fotos/el-gran-lago-de-atitlan-y-sus-volcanes/132968" rel="nofollow noreferrer">http://www.viajeros.com/fotos/el-gran-lago-de-atitlan-y-sus-volcanes/132968</a></p>
  
  <p>Internet Explorer 6 at least tries to save it as Untitled.BMP.</p>
  
  <p>Here is the snippet of code we use in fotos.php:</p>
  
  <pre>
  $archivo = $fotos->ObtenerPathFotoAmazon( $url, null );
  
  if (empty($_GET['nocache'])) {
      header('HTTP/1.0 302 Found');
      header("Expires: ".gmdate("D, d M Y H:i:s", time()+315360000)." GMT");
      header("Cache-Control: max-age=315360000");
  } else {
      header('HTTP/1.0 307 Temporary Redirect');
  }
  
  header('Location: ' . AWS_BUCKET_URL . $archivo);
  die;
  </pre>
  
  <p>Do you know a workaround for this?</p>
  
  <p>EDIT: We are using CloudFront as well.</p>