Problem analysis of php download files
Jul 25, 2016 am 08:57 AM
This article introduces some problems and solutions encountered when downloading files in PHP. Friends in need can refer to them.
When using php to download files, the download box of the browser pops up and the save as operation appears. Sometimes memory overflow and timeout may occur. If it times out, you can set set_time_limit(0); If memory overflow occurs, it may be caused by too much data being retrieved from the database. If a memory overflow occurs when reading from a file, it means that the code reading method is incorrect and it requires calling files or filegetcontens. If it is fopen, give a buffer with a fixed size, read and then write, and there will be no memory overflow. Code:
Copy after login Note: Before output, you need to call @ob_end_flush() once; it cannot be called in a loop, just call it once. @ob_end_flush();//Flush out (send) the contents of the output buffer and close the buffer. File download: content-type://Download format, if the format cannot be parsed by the browser, the download box will pop up
Copy after login |

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

11 Best PHP URL Shortener Scripts (Free and Premium)

Working with Flash Session Data in Laravel

Simplified HTTP Response Mocking in Laravel Tests

Build a React App With a Laravel Back End: Part 2, React

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

12 Best PHP Chat Scripts on CodeCanyon

Announcement of 2025 PHP Situation Survey
