How to fix Firefox trying to "Save Image As" .htm?

We recently introduced Amazon S3 on our site, so we've changed the way we process images. We used the controller call /fotos.php, which would read the file from disk, write statistics, set headers and return the contents of the file as image / jpeg.

Everything went fine until S3. Fotos.php now redirects 302 to a resource in Amazon, and everything works fine, but you cannot save the image in Firefox because it sets its file type to .htm. I found this discussion on this, and it seems like a bug in Firefox:

https://bugs.launchpad.net/ubuntu/+source/firefox-3.0/+bug/207670

The following is the URL of the problem (try saving a large image):

http://www.viajeros.com/fotos/el-gran-lago-de-atitlan-y-sus-volcanes/132968

Internet Explorer 6 at least tries to save it as Untitled.BMP.

Here is the code snippet we use in fotos.php:

$ archivo = $ fotos-> ObtenerPathFotoAmazon ($ url, null);

if (empty ($ _ GET ['nocache'])) {
    header ('HTTP / 1.0 302 Found');
    header ("Expires:" .gmdate ("D, d MYH: 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;

Do you know a workaround for this?

EDIT: We also use CloudFront.

+3
source share
5

header('Content-Type: image/jpeg'); header('Content-Type: image/png');

, , PHP ( -).

$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");
} 

header('Content-Type: image/jpeg');
header("Content-Disposition: attachment; filename='$archivo'");
readfile(AWS_BUCKET_URL .$archivo);
die();
+4

S3 , mimetype, . PUT S3, Content-Type Content-Disposition ( , ). , S3 , - , GET

+5

Firefox (IE , ), , S3 mime .

+1

, script. , .

, .

+1

. , ( ) - "#.jpg" URL-. FF jpg.

0

All Articles