I have a link to download a video which is hosted in our JW Videos Platform. The link is secure (it only works for a set number of minutes) and it works fine.
http://content.bitsontherun.com/videos/QPSxxAok-9zxxLY4Q.mp4?exp=1428027050&sig=602c32cd61617b1ddafd3f47857fcc44
The only issue is that when I click on it, the video loads in the browser by default. Also if I right click on the link and choose "Save Link As", even though it works, the filename is a code instead of the name of the video.
I found a solution to this by changing the link to a form button and having the form call a separate PHP page.
This is the form I use instead of the link ($videoURL is set to the link I wrote above).
<form action="testfile.php" method="post">
<input type="hidden" name="link" value="<?php echo $videoURL ?>" />
<input type="hidden" name="file" value="<?php echo 'My_Video' ?>" />
<button>Download</button>
</form>
This is the code I have in testfile.php
<?php
header('Content-type: application/mp4');
header('Content-disposition: attachment; filename='.$_POST['file'].'.mp4');
readfile($_POST['link']);
?>
The problem is that, even though the download begins automatically and it shows the filename I selected, the download cuts off before the file has finished downloading.
Any ideas as to what may be going wrong here? Why is the download only working for a short while and not for the whole video?