Mobile app version of vmapp.org
Login or Join
Jamie184

: What is the recommended way to handle opening attachments from a webpage? When creating a website, depending on how a browsers Mime-Types are setup, downloading attachments can have different behaviors.

@Jamie184

Posted in: #Links #Save #Windows

When creating a website, depending on how a browsers Mime-Types are setup, downloading attachments can have different behaviors. Is there a website that talks about this and suggests a rule-of-the-thumb that should be taught to all web developers?

For example, among these methods shown below (which doesn't account for all the possibilities), which is preferred and why?


Click the download, prompt with "Save or Open" dialogue and if they choose "open" then open with the Windows default program.
Click the download, prompt with "Save or Open" dialogue, show a "remember this" checkbox, and then open using the web browser in a new window.
Click the download, auto detect the browser mime type and immediately open. Don't save unless they right-click the link and choose "Save As".

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Jamie184

2 Comments

Sorted by latest first Latest Oldest Best

 

@Megan663

I completely agree with @rlb .usa said. You should just provide the link to the file and let user handle it as he wants / is used to.

If you want to force files to be downloaded (for example, like a PDF, which can be read online if user has proper plugins), you can use some headers to handle that.

In PHP:

<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');

// The PDF source is in original.pdf
readfile('original.pdf');
?>

10% popularity Vote Up Vote Down


 

@Turnbaugh106

Well, there are some problems with what you have suggested: namely, different browsers and attachments means that users are going to be doing all sorts of things with attachments.

The unsaid rule of thumb is to use the correct mime-type, provide a download link, and let the user handle the rest.

You go into a little bit of detail about the various (IE) dialogs that may be presented to users - but, the developer doesn't have control over this dialog, it is taken care of automatically. For example, in Chrome, the default action is to start (but not finish) the download and prompt the user down in the bottom download bar about it, there is no pop-up.

Try to avoid those unnecessary details about dialogs, just provide them a link that does what the user would expect it to. The best policy when dealing with users is to make things as intuitive and easy for them as possible (users don't want to think about how to do things, they want it to "just work").

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme