download attribute doesn't working on chrome - php

When I add a download attribute in an anchor tag, it doesn't work at all. I've used it to create download link to download image from the website, but it opens the image instead of downloading. (I've tested this in chrome).
I've tried in different ways:
<a href="admin.jpg" download>Click here to download</a>
and Click here to download

<a> download attribute
If the HTTP header Content-Disposition is present and gives a different filename than this attribute, the HTTP header has priority over this attribute.
If this attribute is present and Content-Disposition is set to inline, chrome gives priority to Content-Disposition.

Related

User chose whether download or stream mp4 media

I'd like to give the user the possibility to download or stream the same media. I tried this way (adding download) but it doesn't work:
<a target='_blank' href='http://another/site/file.mp4' download>DOWNLOAD</a>
<a target='_blank' href='http://another/site/file.mp4'>STREAMING</a>
I create the page using php 5.6
Note that the file is always the same: http://another/site/file.mp4 and comes from a different domain (The <a> urls are in site1 and the media is in site2 )
The download attribute on <a> tags only work with the following:
The URL must be the same origin as the HTML document.
The browser must be Chrome, Firefox, Edge, Safari (10) or Opera (15)
I'm going to assume the URL is from another website, and that's why it's not working.

Download in email did not directly download when click on it #html #php

I want to create a email body that contains download link, when someone click on the download link, it will be immediately download.
But instead the following code open the image in new tab from the browser. How to solve this problem?
$message .= '<a download href="ip-address/img/feature-4.png">Download
Link</a>';**strong text**
p/s:I had tried force browser to download image files on click ,but it did not solve my problem.
Add download attribute to link, but this solution works in modern browsers only.
<img src="/path/to/image" />

full screen button in video tag missing

full screen button in video tag missing when page containing video is loaded externally on another pages div
I have a page external.php . In this page when i use the following code
echo
'<video width="400" controls>
<source src="movie.mp4" type="video/mp4">
</video>';
i get a video with full screen button in it on chrome.But when i try to load this external.php on another page (home.php) div the video is coming but the full screen button is missing.But in IE there is no such problem.
You can either solve this via CSS OR Fullscreen API.
1. CSS
I think you can accomplish this by changing the css for the #document fragments, these are DOM1 specs and supported by all browsers, but about the styling, I'm not sure. The following solution is webkit specific.
You need just to write this code in your css:
video::-webkit-media-controls-fullscreen-button {}
2. Full screen API
If you want to accomplish it by Fullscreen API check below demo first:
Demo Full screen video
As you can see a very simple demo showing HTML5 video in full screen, make sure you're using Chrome dev, webkit or firefox nightly.
For more detail you can check it here.
Browsers may provide a user interface, but shouldn't provide a programmable one.

How can i suggest a file name on file download

i have a webpage with a url going out.
I want to change the filename that the person will receive.
test - click here to download
<?php
header('Content-Disposition: attachment; filename="test.avi"');
?>
The problem is:
I receive the web page and not the file..
When i access the page, a download starts directly.. it's should wait for me to click on the "click here to download".
Also, the downloaded file, is only the actual source code of the page and not the file that i want to download..
Here is a screenshoot, better to explain than my words with my bad english :D
http://i.stack.imgur.com/Si9cP.png
Thanks.
It very simple.
You just need to add download attr to your tag like this:
<a href="http://downloadlink.com/Grizzly.avi" download>test - click here to download</a>
It will start downloading.
For reference
The Content-Disposition needs to go in the header for the file you are offering the user to download (i.e. the avi file in your example).
It doesn't go in the header for the HTML document with the link to the file.

Opening PDF inline in a frame - how to set the file name?

While rendering a PDF inside a frame in Firefox inline, the file name is ignored (click on save as after the PDF opens, and the name of the frame is shown in the save box, instead of the file name). I tried header('Content-Disposition: inline; filename=abc.pdf'); - it doesn't work. The same code works for attachment though, just doesn't work for inline. How to fix this?
This is in PHP, FF 15 and on windows.
You cannot set a file name while embedding the PDF in a frame or a browser tab
you change the title of the frame
you make another button for download where you force the user to download with your custom name

Categories