Here is how I set my header (the video file is a .mp4 one)
header('Content-Description: File Transfer');
header('Content-Type: video/mp4');
// This is for the mp3 file
// header('Content-Type: audio/mp3');
header('Content-Disposition: attachment; filename=' . $file);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header("Cache-Control: private", false);
header('Pragma: public');
header('Content-Length: ' . $file_size);
But anyway, the code works when not executed with CakePHP, so it
should not be a header problem.
On Oct 3, 5:11 pm, somebody who carez <somebodywhoca...@gmail.com>
wrote:
> You may need to set a correct header for the file to get the browser to
> process it correctly.
>
> http://php.net/manual/en/function.readfile.php
>
> Thank you,
> -Alex Goretoy
>
>
>
>
>
>
>
> On Mon, Oct 3, 2011 at 10:03 AM, thomaus <tho...@saimiris.com> wrote:
> > Hi there,
>
> > I'm experiencing a very strange problem. I'm trying to remotely
> > download a video file.
>
> > I've done a very basic PHP code using the readfile() function. This
> > code works absolutely fine.
>
> > Now when I copy / paste the exact same code into my CakePHP
> > controller, the URL works, a file is actually downloaded, the size of
> > the downloaded file is correct, but the type of the file is not
> > recognized, i.e. the video can't be played.
> > I tried the same with a mp3 file, just to check if the problem was not
> > a video format one, and the same problem happened. And again the
> > original PHP code is working fine with this mp3 file.
>
> > I have added these 3 lines just in case in my controller :
> > Configure::write('debug', 0);
> > $this->autoLayout = false;
> > $this->autoRender = false;
> > but the same problem happens.
>
> > Any idea?
>
> > --
> > Our newest site for the community: CakePHP Video Tutorials
> >http://tv.cakephp.org
> > Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
> > others with their CakePHP related questions.
>
> > To unsubscribe from this group, send email to
> > cake-php+unsubscribe@googlegroups.com For more options, visit this group
> > athttp://groups.google.com/group/cake-php
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment