使用PHP读取文件会产生500错误 [英] Reading a File with PHP gives 500 error

查看:353
本文介绍了使用PHP读取文件会产生500错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本,该脚本使用readfile()读取mp3文件(我也尝试过使用循环的fread()).在一个特定的文件上,我得到了500错误.其他所有文件似乎都没问题.

I have a script which reads a mp3 file with readfile() (I have also tried fread() with a loop). And on one particular file I am getting a 500 error. All other files seem to read just fine.

当我查看服务器上的错误日志时,我发现尝试读取此特定文件时遇到了PHP内存错误.

When I review the error log on my server I notice I am getting a PHP memory error when ever this particular file is attempted to be read.

有人可以给我一些可能发生的情况的提示吗?

Can anyone give me some pointers as to what might be going on?

推荐答案

您已经指出了问题-PHP的内存不足. PHP中的最大内存使用量受ini设置的限制.

You already pointed out the problem - PHP is running out of memory. Maximum memory usage in PHP is limited by an ini setting.

您可以使用 ini_set 或者您可以在 php.ini 文件中进行设置所有脚本的效果:

Or you can set it in your php.ini file so it takes effect for all scripts:

memory_limit = 64M;

最后,您可以使用

Finally, you can see the memory used by the currently executing script with memory_get_usage()

这篇关于使用PHP读取文件会产生500错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆