CodeIgniter Forums
How force download mp4 file - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: How force download mp4 file (/showthread.php?tid=74241)



How force download mp4 file - omid_student - 09-02-2019

Hi
I have 10 video files with mp4 format
I download this files from my php script
My code is :
PHP Code:
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($filename).'?id='.time());
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' filesize($filename));
readfile($filename); 

But speed is low when user try to download
and when i use redirect(base_url().$filename); speed is good and user can watch video speedly

M goal from this way is user cannnot download video and have to watch it with my php script file

Thanks


RE: How force download mp4 file - php_rocs - 09-02-2019

@omid_student,

There is a lot of things to trouble shoot. What kind of connection does your user have? Are there any download limitations from your hosting company? How big are the videos?


RE: How force download mp4 file - InsiteFX - 09-02-2019

Here are a few different ways of doing it:

Force download MP4 file – PHP or .htaccess


RE: How force download mp4 file - omid_student - 09-02-2019

(09-02-2019, 08:09 AM)php_rocs Wrote: @omid_student,

There is a lot of things to trouble shoot.  What kind of connection does your user have?  Are there any download limitations from your hosting company?  How big are the videos?
Thanks
Files are about 20 mb
My users are two user now
When i redirect to video,speed is good

(09-02-2019, 09:00 AM)InsiteFX Wrote: Here are a few different ways of doing it:

Force download MP4 file – PHP or .htaccess
Thank you
Do you can say why speed is low when i try send mp4 to header?


RE: How force download mp4 file - InsiteFX - 09-02-2019

No idea why it would be slow using the header, the users internet speed could slow it down.


RE: How force download mp4 file - omid_student - 09-02-2019

(09-02-2019, 11:58 AM)InsiteFX Wrote: No idea why it would be slow using the header, the users internet speed could slow it down.
Internet speed is very good


RE: How force download mp4 file - InsiteFX - 09-02-2019

you could try doing an ob_clean(); first and see if that helps.


RE: How force download mp4 file - omid_student - 09-03-2019

(09-02-2019, 04:30 PM)InsiteFX Wrote: you could try doing an ob_clean(); first and see if that helps.
i tried it already my friend


RE: How force download mp4 file - InsiteFX - 09-03-2019

Try running the CI Profiler and check your log files in CI and on the server.


RE: How force download mp4 file - omid_student - 09-03-2019

(09-03-2019, 02:45 AM)InsiteFX Wrote: Try running the CI Profiler and check your log files in CI and on the server.
Ok Thanks