pepperoni
asked on
downloading on Mac
hi, i've got this downloading problem. my webserver is in a Mac with OSX. i have a page where i show thumbnails of pictures and if the viewers click on a button, the corresponding piture will be downloaded. here's the part of the code:
download.php:
.
.
$path = $dirpath. "/" .$filename;
header("Content-type: application/octet-stream") ;
header("Content-Dispositio n: attachment; filename=".$filename);
header("Content-Transfer-E ncoding: binary");
$fp = fopen($path, 'rb');
fpassthru($fp);
flush();
.
.
if i access the page from a Windows PC using IE or from a Linux PC using Netscape or Konqueror, it works perfectly fine. but if i access it from a Mac OSX using IE for Mac, it won't download the image file, instead it just shows the image in its original size in the same frame as the download page.
i have no idea what's wrong. please help. thanks!
download.php:
.
.
$path = $dirpath. "/" .$filename;
header("Content-type: application/octet-stream")
header("Content-Dispositio
header("Content-Transfer-E
$fp = fopen($path, 'rb');
fpassthru($fp);
flush();
.
.
if i access the page from a Windows PC using IE or from a Linux PC using Netscape or Konqueror, it works perfectly fine. but if i access it from a Mac OSX using IE for Mac, it won't download the image file, instead it just shows the image in its original size in the same frame as the download page.
i have no idea what's wrong. please help. thanks!
ASKER
hi JD, thanks for the comment.
I tried accessing downloading the images using different PCs with different Internet Explorer versions. for IE 5.0, the image files are downloaded properly (with the pop up box appearing asking the user to whether to open it from the current location or save it to disk). but with the IE 5.xx's, the gif and jpg files are opened and shown in the browser. that is because the newer version browsers can recognize the the files so they just show them, right? is there a way or tricks with the codes that will stop the browsers from showing the jpg and gif files and have the pop up download box appear instead? pls. help.
thanks.
I tried accessing downloading the images using different PCs with different Internet Explorer versions. for IE 5.0, the image files are downloaded properly (with the pop up box appearing asking the user to whether to open it from the current location or save it to disk). but with the IE 5.xx's, the gif and jpg files are opened and shown in the browser. that is because the newer version browsers can recognize the the files so they just show them, right? is there a way or tricks with the codes that will stop the browsers from showing the jpg and gif files and have the pop up download box appear instead? pls. help.
thanks.
Can you try changing your content-type to ...
image/jpeg
or
image/gif
and try again.
image/jpeg
or
image/gif
and try again.
header("Content-type: image/jpeg");
or
header("Content-type: image/gif");
http://www.isi.edu/in-notes/iana/assignments/media-types
http://www.isi.edu/in-notes/iana/assignments/media-types/media-types
is a good list of media types.
or
header("Content-type: image/gif");
http://www.isi.edu/in-notes/iana/assignments/media-types
http://www.isi.edu/in-notes/iana/assignments/media-types/media-types
is a good list of media types.
ASKER
thanks for the comment RQuadling.
i tried it, but still not working.
i tried it, but still not working.
http://www.isi.edu/in-notes/iana/assignments/media-types/application/applefile
describes some issues with sending files to a MAC using MIME.
There is something called AppleSingle and AppleDouble.
But I do not know if the file you want to send has to be a mac file to start with.
What happens if you right click an image and save it. Do you get a single file of the right size? Or is it packaged in some way so that the file knows its type? Does the mac use file extensions like wintel pcs?
Can you try ...
header("Content-Type: application/mac-binhex40; name=\"image.jpg\");
describes some issues with sending files to a MAC using MIME.
There is something called AppleSingle and AppleDouble.
But I do not know if the file you want to send has to be a mac file to start with.
What happens if you right click an image and save it. Do you get a single file of the right size? Or is it packaged in some way so that the file knows its type? Does the mac use file extensions like wintel pcs?
Can you try ...
header("Content-Type: application/mac-binhex40; name=\"image.jpg\");
ASKER
hi, nope, not a mac file. just image files jpg, gif, pict. the problem is not only with IEs in Mac but also in Windows PCs using Internet Explorers with versions higher than 5.0 . I installed IE 5.5 SP 2 in a Windows PC with IE 5.5 and the problem was gone. :)
ASKER
hi, nope, not a mac file. just image files jpg, gif, pict. the problem is not only with IEs in Mac but also in Windows PCs using Internet Explorers with versions higher than 5.0 . I installed IE 5.5 SP 2 in a Windows PC with IE 5.5 and the problem was gone. :)
I must admit, I've NEVER seen the browser fail to show an image if the image is a JPG or a GIF file. The only way to get the file saved is to right click and choose save. I think you used to be able to do shift and left click images, but that doesn't seem to work in IE6.
So.
What happens if you set the name to a type that is NOT an image?
I have to say that you are seeing normal behaviour.
If you can give me the URL of a page that contains images that when I click them, they automatically save, then I can find out what is being sent to me to tell my browser to NOT show it but to ask to save it.
Regards,
Richard Quadling.
So.
What happens if you set the name to a type that is NOT an image?
I have to say that you are seeing normal behaviour.
If you can give me the URL of a page that contains images that when I click them, they automatically save, then I can find out what is being sent to me to tell my browser to NOT show it but to ask to save it.
Regards,
Richard Quadling.
ASKER
hi richard,
i do not know any page in the web that does that.
i do not know any page in the web that does that.
ASKER
hi richard,
i do not know any page in the web that does that.
i do not know any page in the web that does that.
Can you show your current code again.
I want to try this on a windows pc. Just to make sure.
Is your browser fully uptodate for it's version? Have you tried the latest version or a different browser?
Exploiting the mime type should be able to force a download. This is how some of the viruses work, by saying they are one thing when they are in fact another.
Regards,
Richard Quadling.
I want to try this on a windows pc. Just to make sure.
Is your browser fully uptodate for it's version? Have you tried the latest version or a different browser?
Exploiting the mime type should be able to force a download. This is how some of the viruses work, by saying they are one thing when they are in fact another.
Regards,
Richard Quadling.
ASKER
hi Richard, sorry for the late reply. anyway, here's the code;
download.php
$path = $dirpath. "/" .$filename;
header("Content-type: application/octet-stream") ;
header("Content-Dispositio n: attachment; filename=".$filename);
header("Content-Transfer-E ncoding: binary");
$fp = fopen($path, 'rb');
fpassthru($fp);
flush();
download.php
$path = $dirpath. "/" .$filename;
header("Content-type: application/octet-stream")
header("Content-Dispositio
header("Content-Transfer-E
$fp = fopen($path, 'rb');
fpassthru($fp);
flush();
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry for being so late.
But thanks a lot for the help.
But thanks a lot for the help.
No problems. What was your solution?
ASKER
We just let it like that. In the project documentation we wrote it as IE limitation of versions higher than 5.0. Installing IE 5.5 SP2 (with IE 5.5 installed) will solve the problem.
basically there will be difference in the way browser works. Browser might try to be inteligent and display file if it can recognise file from its extension. its not the fault of code, but more of browser implementation issue.
JD