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-Disposition: attachment; filename=".$filename);
header("Content-Transfer-Encoding: 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!
pepperoniAsked:
Who is Participating?
 
Richard QuadlingConnect With a Mentor Senior Software DeveloperCommented:
I run W2K Pro, with Sambar Server and PHP V4.2.1.

Your script will ask me to save the file rather than download it.

Fair enough.

Can you provide an online version where your script is failing?

Can you try ...

header("Content-Disposition: attachment; filename=unknown");

Do you get an image shown then?

On a PC, this SHOULD give you the "Save" question as there is no extension.

I would assume the same on a mac, but I do not know what links a file to the correct editor/viewer? How does the Mac OS know that a document is to be handled by your WP and images by Photoshop? Is it via the extension (like windows) or what? Are resource files important? Does it scan the actual file and see what is in it and decide upon that to show an image if the header obeys the rules?

Richard.
0
 
dkjariwalaCommented:
Okie.
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
0
 
pepperoniAuthor Commented:
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.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Richard QuadlingSenior Software DeveloperCommented:
Can you try changing your content-type to ...

image/jpeg

or

image/gif

and try again.
0
 
Richard QuadlingSenior Software DeveloperCommented:
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.

0
 
pepperoniAuthor Commented:
thanks for the comment RQuadling.

i tried it, but still not working.
0
 
Richard QuadlingSenior Software DeveloperCommented:
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\");


 
0
 
pepperoniAuthor Commented:
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. :)
0
 
pepperoniAuthor Commented:
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. :)
0
 
Richard QuadlingSenior Software DeveloperCommented:
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.
0
 
pepperoniAuthor Commented:
hi richard,

i do not know any page in the web that does that.
0
 
pepperoniAuthor Commented:
hi richard,

i do not know any page in the web that does that.
0
 
Richard QuadlingSenior Software DeveloperCommented:
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.
0
 
pepperoniAuthor Commented:
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-Disposition: attachment; filename=".$filename);
   header("Content-Transfer-Encoding: binary");
   $fp = fopen($path, 'rb');
   fpassthru($fp);
   flush();
0
 
pepperoniAuthor Commented:
Sorry for being so late.
But thanks a lot for the help.
0
 
Richard QuadlingSenior Software DeveloperCommented:
No problems. What was your solution?
0
 
pepperoniAuthor Commented:
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.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.