Welcome Guest, Not a member yet? Register   Sign In
How force download mp4 file
#1

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
Reply
#2

@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?
Reply
#3

Here are a few different ways of doing it:

Force download MP4 file – PHP or .htaccess
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

(This post was last modified: 09-02-2019, 09:57 AM by omid_student.)

(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?
Reply
#5

No idea why it would be slow using the header, the users internet speed could slow it down.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#6

(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
Reply
#7

you could try doing an ob_clean(); first and see if that helps.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#8

(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
Reply
#9

Try running the CI Profiler and check your log files in CI and on the server.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#10

(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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB