[英]Uploading files to server using php
I can successfully upload files upto 3-4 MB. 我可以成功上传高达3-4 MB的文件。 But when I try to upload files greater than 4 MB, it starts upload for sometime and then shows "This webpage is not available" error.
但是,当我尝试上传大于4 MB的文件时,它开始上传一段时间,然后显示“此网页不可用”错误。 I have hosted the site in 000webhost.
我已经在000webhost中托管了该站点。 But in localhost, I can easily upload larger files as well.
但是在localhost中,我也可以轻松上传较大的文件。 Please help me out of this.
请帮助我。
You need to set the value of upload_max_filesize and post_max_size in your php.ini : 您需要在php.ini中设置upload_max_filesize和post_max_size的值:
; Maximum allowed size for uploaded files.
upload_max_filesize = 40M
; Must be greater than or equal to upload_max_filesize
post_max_size = 40M
(and restart apache) (并重新启动apache)
I believe that you have 我相信你有
Enough permission to upload files 足够的权限来上传文件
And increased upload_max_filesize
and post_max_size
并增加了
upload_max_filesize
和post_max_size
upload_max_filesize = 40M
post_max_size = 40M
Note : 注意 :
000webhost.com
is a free hosting site and you can't expect good speed and it would fail in most cases. 000webhost.com
是一个免费的托管网站,您不能指望它提供良好的速度,并且在大多数情况下会失败。 If you want to see good response better try in a paid hosting or try in some free app hosters like heroku 如果您想获得更好的响应,请尝试使用付费托管服务,或尝试使用一些免费的应用托管服务商,例如heroku
Update according to user's Comment : 根据用户评论更新:
I can do that in localhost. But where can I find the php.ini file as I have already hosted the site
You can't find the php.ini
in online server. 您无法在在线服务器中找到
php.ini
。 But you can set it using .htaccess
files and other few ways.. 但是您可以使用
.htaccess
文件和其他几种方式进行设置。
Create a .htaccess
file and inside it have the following code, then you can achieve your need. 创建一个
.htaccess
文件,并在其中包含以下代码,即可满足您的需求。
php_value upload_max_filesize 40M
php_value post_max_size 40M
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.