PHP output file on disk to browser

前端 未结 6 2083
轻奢々
轻奢々 2020-11-27 19:18

I want to serve an existing file to the browser in PHP. I\'ve seen examples about image/jpeg but that function seems to save a file to disk and you have to create a right si

6条回答
  •  囚心锁ツ
    2020-11-27 20:03

    This should get you started: http://de.php.net/manual/en/function.readfile.php

    Edit: If your web server supports it, using

    header('X-Sendfile: ' . $filename);
    

    where file name contains a local path like

    /var/www/www.example.org/downloads/example.zip
    

    is faster than readfile().

    (usual security considerations for using header() apply)

提交回复
热议问题