How to upload video using php script

In my program, I want to add a download option to download the video now. I tried this code:

$psp = "Tom_20_amp__20Jerry_20race-1.flv"; header("Content-type:application/octet-stream"); header("Content-Disposition:attachment;filename=$psp"); 

But I get this error:

"C: \ DOCUME ~ 1 \ ADMINI ~ 1 \ LOCALS ~ 1 \ Temp \ Tom_20_amp__20Jerry_20race-1-5.flv" is not a valid FLV file.

video streaming. please guide me

+4
source share
2 answers

Change your title:

 header("Content-type:application/octet-stream"); 

To:

 header("Content-type: video/flv"); 

Then you can do:

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

If you want to allow file downloads instead of streaming, something like this should work. You obviously need to change paths.

 // We'll be outputting a PDF header('Content-type: application/pdf'); // It will be called downloaded.pdf header('Content-Disposition: attachment; filename="download.pdf"'); // The PDF source is in original.pdf readfile('original.pdf'); 

EDIT

In your case, it will be something like this.

 // We'll be outputting a video header('Content-type: video/flv'); // It will be called video.flv header('Content-Disposition: attachment; filename="video.flv"'); // The PDF source is in original.flv readfile('original.flv'); 
+1
source

Source: https://habr.com/ru/post/1334643/


All Articles