User chose whether download or stream mp4 media - php

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.

Related

Internet Explorer 11 losing cookie of iframe embedded website when link target is "_blank" - same domain, different subdomain

When embedding https://subdomain-b.example.com with an iframe on https://subdomain-a.example.com and then clicking a link within the iframe that opens in a new tab/window the cookie gets lost.
I am not sure if it has anything to do with it, but everything is strictly https.
Code on https://subdomain-a.example.com:
<iframe src="subdomain-b.example.com/index.php"></iframe>
Code on https://subdomain-b.example.com/index.php: Important that the link opens in _blank
<?php
setcookie("TestCookie", "someValue");
?>
link
Code on https://subdomain-b.example.com/showcookie.php:
<?php
print_r($_COOKIE);
The response on https://subdomain-b.example.com/showcookie.php is empty.
This works on Firefox, Chrome and Edge.
This must have something to do with how https://subdomain-a.example.com treats iframe content, it works on some instances and on others it does not.

download attribute doesn't working on chrome

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.

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.

have img src = dl-main.php?f=filename.jpg retrieve said image from remote server

I am trying to do the following; dynamically pick a server with the image on it, and then show said image in img src="". Yeah I know, I am horrible at explaining stuff like this but this should clear it up:
dl-main.php (on server0.domain.com)
$url = 'http://server2.domain.com/offerimage.php?f='.$_GET["f"];
header( 'Location: '.$url ) ;
offerimage.php (on server2.domain.com)
//Lots of link-protection stuff here
$f = "/".$_GET["f"];
$url = 'http://server2.domain.com'.$uri_prefix.$m.'/'.$t_hex.$f;
echo' <img src="'.$url.'"></img> ';
dl.php (on many other servers)
img src="http://server0.domain.com/dl-main.php?f=lalala.gif"
So it pretty much goes like this: Random person adds img src directing to dl-main.php?f=filename on server0. server0 then decides which server will provide the image. In the above example I am using only one server; server2
Now I simply want dl.php to show the photo hosted on server2.domain.com .
As it stands when I directly visit dl-main.php it succesfully redirects me to dl.php, which then succesfully shows me the image I requested. But when I use dl-main.php in a img src it doesn't show the image. I didn't expect it to work but it was worth a shot, but now I don't know what to do anymore :o
I hope this failed attempt is a good example of what I'm trying to accomplish here.
Thanks!
Here's the problem. You call image from server0 using:
<img src="http://server0.whatever/dl-main.php?f=thatimage.something" />
Where the dl-main.php code redirects to server2. Here, you do:
echo' <img src="'.$url.'"></img> ';
So basically the original img tag would get another img tag instead of the image data. That's why the browser can't render the image. You should echo the content of the image instead of an img tag.
Try using your browser's developer tools and check the request to server2 to verify my guess.
It can't work, your second script (offerimage) is producing text/plain, you should produce image/...in order to use img

Using Firefox to download xml word doc. Image won't show

We have an xml word doc with image on title page that downloads correctly via ftp but the image is always missing if we try to download it via a link in an html page. We're using Firefox if that makes a difference. But we also tried it using Opera, with the same results.
Here's the link we're using:
$fileDest = './mydoc.xml';
<a type="msword" href="<?php echo $fileDest; ?>"><input type="button" value="Download Document" /></a>
You serve different files via FTP and HTTP.

Categories