Solved

downloading on Mac

Posted on 2002-06-21
17
305 Views
Last Modified: 2011-09-20
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!
0
Comment
Question by:pepperoni
  • 9
  • 7
17 Comments
 
LVL 5

Expert Comment

by:dkjariwala
Comment Utility
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
 

Author Comment

by:pepperoni
Comment Utility
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
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
Can you try changing your content-type to ...

image/jpeg

or

image/gif

and try again.
0
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
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
 

Author Comment

by:pepperoni
Comment Utility
thanks for the comment RQuadling.

i tried it, but still not working.
0
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
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
 

Author Comment

by:pepperoni
Comment Utility
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
 

Author Comment

by:pepperoni
Comment Utility
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
Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
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
 

Author Comment

by:pepperoni
Comment Utility
hi richard,

i do not know any page in the web that does that.
0
 

Author Comment

by:pepperoni
Comment Utility
hi richard,

i do not know any page in the web that does that.
0
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
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
 

Author Comment

by:pepperoni
Comment Utility
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
 
LVL 40

Accepted Solution

by:
RQuadling earned 75 total points
Comment Utility
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
 

Author Comment

by:pepperoni
Comment Utility
Sorry for being so late.
But thanks a lot for the help.
0
 
LVL 40

Expert Comment

by:RQuadling
Comment Utility
No problems. What was your solution?
0
 

Author Comment

by:pepperoni
Comment Utility
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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PHP Startup Error 12 29
Adding Extra Information box 4 24
resizeing PHP image 2 21
delete database record with modal 21 28
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now