当前位置:网站首页>PHP get (remote) large file method record
PHP get (remote) large file method record
2022-06-12 10:30:00 【P P PHP】
Usually PHP Error getting file , Will use file_get_contents(). But when getting large files , May report such a mistake :
Allowed memory size of 134217728 bytes exhausted (tried to allocate 49422336 bytes)This is because file_get_contents() Error getting file , Will put the contents of the file into a string , When the string size exceeds php.ini In the setting of memory_limit When parameters are , It's a mistake . The solution is to change the parameter a little larger , It's usually 128M, It can be modified a little larger . But you need to restart the server after the modification , It's troublesome . You can also change this value dynamically , Use ini_set. I use the following method to solve :
$handle = fopen(" Remote file address ", "rb");
$fp = fopen('vv.mp4', 'w');// Open a file ,
while (!feof($handle)) { // Cycle through remote files
$contents = '';
$contents = fread($handle, 1048576);// Each read 1M
fwrite($fp, $contents);// Writes the contents of a remote file to an open vv.mp4 file
}
fclose($handle);
fclose($fp);In this way, even the largest file can be read , It's just that there are more cycles , Take longer .
边栏推荐
- 浅谈调和形状上下文特征HSC对3DSC的改进
- PHP: seven cattle cloud upload file
- Valentina Studio Pro for Mac(mac数据库管理软件)
- reflex
- PHP generate schedule
- Leetcdoe 2037. 使每位学生都有座位的最少移动次数(可以,一次过)
- Tp6+memcached configuration
- Binassii module - converting between binary and ASCII
- PHP maximum balance method to solve the problem that the sum of the final percentages is not equal to 100
- Pseudo static setting of access database in win2008 R2 iis7.5
猜你喜欢

机器学习不是你想用,想用就能用

学生管理系统

Introduction to IOT

Student management system
![[Wayland] Wayland introduction and customized guidance](/img/4e/655d484ca7787f39aab446fdb1ae74.jpg)
[Wayland] Wayland introduction and customized guidance

【机器学习】基于鸢尾花(iris)数据集的逻辑回归分类实践

Leetcode2154. Multiply the found value by 2 (binary search)

Raw socket usage

Mqtt protocol Chinese version

How to refund the pre-sale deposit of JD 618 in 2022? Can JD 618 deposit be refunded?
随机推荐
Golang start service background daemon
【机器学习】基于鸢尾花(iris)数据集的逻辑回归分类实践
2022淘宝618超级喵运会玩法来了 超级喵运会有哪些攻略方法
PHP generate schedule
How to play the 2022 Taobao 618 Super Cat Games? Playing skills of 2022 Taobao 618 Cat Games
properties中文乱码
Chapter 3 search
VSCode代码调试技巧
How to play the 618 super cat games on Taobao? Here comes the introduction to the overall activities of the Super Cat Games
PostgreSQL uses stored procedures to splice multiple tables and query data
Raw socket usage
93. 获得内网的所有IP地址
在App内跳转微信,打开微信
ASP. Net core permission system practice (zero)
Circuitbreaker fuse of resilience4j -- Measurement of circuitbreakermetrics index
np. Meshgrid() function and coordinate position generation in 3D space and numpy Introduction to repeat() function
不需要安装防毒软件的系统Chromebook
SAP Hana error message sys_ XSA authentication failed SQLSTATE - 28000
2022 JD 618 Comment rembourser le dépôt de pré - vente? Le dépôt JD 618 peut - il être remboursé?
[CEGUI] window environment compilation