如何解决上传大文件(例如超过10兆)出错的问题?

peakcn 2002-05-02 07:43:26
我的环境是:
WINDOWS 2000 SERVER

IIS5.0

PHP4.0.6

...全文
962 39 打赏 收藏 转发到动态 举报
写回复
用AI写文章
39 条回复
切换为时间正序
请发表友善的回复…
发表回复
hcgui 2002-05-24
  • 打赏
  • 举报
回复
关注!
zyme 2002-05-18
  • 打赏
  • 举报
回复
PHP程序中copy()之前加
set_time_limit(180);
甚至
set_time_limit(0);
LeeMaRS 2002-05-12
  • 打赏
  • 举报
回复
如果想靠传统的PHP上传方法,肯定不行的了.
peakcn 2002-05-12
  • 打赏
  • 举报
回复
高手们

快来告诉解决方法呀!!
qiushuiwuhen 2002-05-12
  • 打赏
  • 举报
回复
move_uploaded_file
(PHP 4 >= 4.0.3)

move_uploaded_file -- Moves an uploaded file to a new location
Description
bool move_uploaded_file ( string filename, string destination)


This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.

If filename is not a valid upload file, then no action will occur, and move_uploaded_file() will return FALSE.

If filename is a valid upload file, but cannot be moved for some reason, no action will occur, and move_uploaded_file() will return FALSE. Additionally, a warning will be issued.

This sort of check is especially important if there is any chance that anything done with uploaded files could reveal their contents to the user, or even to other users on the same system.

Note: When safe mode is enabled, PHP checks whether the file(s)/directories you are about to operate on have the same UID as the script that is being executed.

Note: move_uploaded_file() is not affected by the normal safe-mode UID-restrictions. This is not unsafe because move_uploaded_file() only operates on files uploaded via PHP.


Warning
If the destination file already exists, it will be overwritten.


See also is_uploaded_file(), and the section Handling file uploads for a simple usage example.

如果出现
Fatal error: Maximum execution time of 30 seconds exceeded in e:\server\program\apache\htdocs\update\index.php on line 2

修改php.ini中的

max_execution_time integer
This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. This helps prevent poorly written scripts from tying up the server. The default setting is 30.

The maximum execution time is not affected by system calls, the sleep() function, etc. Please see the set_time_limit() function for more details.



peakcn 2002-05-10
  • 打赏
  • 举报
回复
leemars(小菜虎) :你的说法我同意
wasy 2002-05-10
  • 打赏
  • 举报
回复
move_uploaded_file的用法和copy一樣
不同的是前者祇能上傳用post方法上傳的文件
用is_uploaded_file可以判斷上傳文件是否通過post方法
LeeMaRS 2002-05-10
  • 打赏
  • 举报
回复
to peakcn() : 我个人觉得IIS的漏洞比APACHE要多得多:)

不过安全方面,我也不是很在行的.
peakcn 2002-05-09
  • 打赏
  • 举报
回复
cf_journey(陶醉):

已经设置了,还是不好用呀

还有呀,整个程序都是用PHP来开发的,是不可能再允许其它的开发语言介入的,除了JAVASCRIPT呀。

cf_journey 2002-05-09
  • 打赏
  • 举报
回复
好象可有一个函数可用来设置程序执行的时间,好象是SET_MAXTIME(),使用这个函数可以解决上传超时的问题,要上传大文件,我建议使用PERL程序.我从前也碰到过一样的问题.
cf_journey 2002-05-09
  • 打赏
  • 举报
回复
peakcn 2002-05-09
  • 打赏
  • 举报
回复
LeeMaRS(小菜虎) :谢谢你的多次解答

我了解到APACHE在WIN32中有很多已知的问题,所以一般情况下是不会采用WIN2000+APACHE的

APACHE在WIN32下有如下警告:

APACHE的WIN32发布版本仍旧应该看作是测试(BETA)质量的代码,它不符合UNIX发布版本在稳定性和安全性上的正常标准。尚有许多已知的错误(BUG)和不一致性。在APACHE的WIN32版本中存在安全漏洞的可能性也很大。
peakcn 2002-05-09
  • 打赏
  • 举报
回复
wasy(嘻嘻哈哈) :请问move_uploaded_file是什么样的方法呀,能说详细点儿吗?谢谢!


peakcn 2002-05-09
  • 打赏
  • 举报
回复
zzgl(昊) :用PHP写FTP上传我早已经会了,可是别忘了,提交一个FILE表单时是要先把文件上传到服务器的临时目录中的,所以还是有大文件上传的问题呀!


zzgl 2002-05-08
  • 打赏
  • 举报
回复
php.ini文件的配置和上面说的差不多,把最大上传文件修改就好了。
上传的方法有两种:
1.copy
2.ftp
用copy传送小文件还可以,但是传送大文件,如100M的就不行了。
具体做法,参考php的帮助文件。
首先连接ftp地址。
然后将文件及路径输入就可以传送了。
wasy 2002-05-08
  • 打赏
  • 举报
回复
修改php.ini(注意先用phpinfo察看php.ini位置)
1.upload_max_filesize=10M
2.max_execution_time=700
3.memory_limit=15M

我用copy和move_uploaded_file上傳一個8M的文件,試了三次,都成功了
slayerbb 2002-05-07
  • 打赏
  • 举报
回复
将时间限制改掉,行不行?
如果不行的话,建议用ftp吧...
peakcn 2002-05-07
  • 打赏
  • 举报
回复
不是呀,点击完“上传”按钮后立即出现此错误页面,已经在多个服务器上试过了,都不行,这些“服务器”有一半在本地(百兆局域网)。

再次感谢你们
LeeMaRS 2002-05-07
  • 打赏
  • 举报
回复
好.就我目前所做的测试来说(我的是Apache):

1.只修改upload_max_filesize = 2M,改为upload_max_filesize = 100M
大于2M的文件能上传了,但是到了某一大小的时候,就不能上传.提示:

Warning: Unable to open '' for reading: Permission denied in e:\server\program\apache\htdocs\update\index.php on line 13

2.经楼上的朋友提示,修改post_max_size = 8M,改为post_max_size = 100M
上传一RM(7xM).
最后提示:
Fatal error: Maximum execution time of 30 seconds exceeded in e:\server\program\apache\htdocs\update\index.php on line 2

看见了吧?最后是被时间限制住了.

我是在本机上测试的.
slayerbb 2002-05-07
  • 打赏
  • 举报
回复
呵呵,说吧,封寒月,说说你的想法...
殷剑平等得很急也....
呵呵
加载更多回复(19)

21,894

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧