When a file is opened in a new window, the window is automatically closed if the file is unrecognizable.

Source: Internet
Author: User

For download, use contenttype: Application/octet-stream and content-Disposition: attachment; filename = file. ext

You can control the file to be completely saved as a download, so you do not need to open a new window.

 

However, if an image is opened online, for example, in order not to affect the browsing of the current window, a new window should be opened to display the image:

<A href = "openfile? File = file. Ext "target =" _ blank "> open </a>

This is no problem. The problem is that if the opened file is unrecognizable by the browser, it is changed to download or selectProgramOpen. If the pop-up window cannot be closed automatically,

It will greatly affect the user's feelings. Therefore, to control the _ blank function, the server must

Content-Disposition: attachment; filename = file. Ext: Content-Disposition: inline; filename = file. Ext.

That is, if the content-disposition is inline when the file is opened, the _ blank window specified by target is automatically closed if the browser cannot interpret the opened file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.