1

I have a .mp4 video in my /videos folder.

I want the user to click a link and then for the video to download to their computer or samsung galaxy.

When I click on my link it downloads the video. However, it's corrupt. It literally has a file size of 0kb.

This is the link www.example.com/download.php

On this page has the following code

<?php

$download = "http://www.example.com/videos/video.mp4";

header("Content-type: video/mp4");
header("Content-Disposition:attachment;filename=\"$download\"");
//allways a good idea to let the browser know how much data to expect
header("Content-length: " . filesize($download) . "\n\n");
echo file_get_contents($psp); //$download should contain the full path to the video

Does anyone know why this isn't working?

schweerelos
  • 2,189
  • 2
  • 17
  • 25
user3620531
  • 55
  • 2
  • 2
  • 11

1 Answers1

0

$download needs to be the full path to a local file in the file system, not a URL -- for example,

$download = "/videos/video.mp4";

Have a look at this answer. Also, what's in your $psp variable?

Community
  • 1
  • 1
schweerelos
  • 2,189
  • 2
  • 17
  • 25