上传的文件大于服务器 POST 设置允许的大小

发布于 2024-12-20 12:55:01 字数 158 浏览 2 评论 0原文

我正在创建一个网站,用户可以在其中上传他的文档。 服务器设置:

upload_max_filesize 2M
post_max_size 2M

FTP上传无限制。

有没有办法允许用户通过 FORM 上传更大的文件?

I'm creating a site in which user can upload his docs.
Settings on server:

upload_max_filesize 2M
post_max_size 2M

The FTP uploading is unlimited.

Is there a way to allow the user upload larger files via FORM?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

无人问我粥可暖 2024-12-27 12:55:01

您可以尝试通过 ini_set 函数在运行时设置 upload_max_filesize 的 php 值。
但这是行不通的,因为变量没有及时设置,因此它无法真正覆盖 php.ini 指令。

因此,如果您无法访问 apache conf,您可以尝试在 .htaccess 中设置此类内容,

我还建议设置 post_max_size 这会很有帮助。

php_value upload_max_filesize 32M
php_value post_max_size 32M

You could try by ini_set function to set the php values for upload_max_filesize at runtime.
but that won't work because the variable is not setted in time so that it can really ovverride the php.ini directives.

So, if you can't access the apache conf, you can try to set this kind of things in the .htaccess

I'd also suggest to set the post_max_size that could help a lot.

php_value upload_max_filesize 32M
php_value post_max_size 32M
梦初启 2024-12-27 12:55:01

如果您无权编辑 php.ini,您可以使用 .htaccess 文件:

php_value upload_max_filesize 10M

根据 http://www.php.net/manual/en/ini.list.php

条目可以在 php.ini、.htaccess 或 httpd.conf 中设置

值得注意的是,与往常一样,如果您编辑 php.ini 或 apache httpd.conf,则需要重新启动 apache,然后才能看到 Web 中反映的更改环境。

If you don't have access to edit php.ini, you can use your .htaccess file:

php_value upload_max_filesize 10M

According to http://www.php.net/manual/en/ini.list.php:

Entry can be set in php.ini, .htaccess or httpd.conf

It's worth noting that as always, if you edit your php.ini or apache httpd.conf you'll need to restart apache before you see the changes reflected in your web environment.

浸婚纱 2024-12-27 12:55:01

POST 是 HTTP,表单也是。 HTTP 不是 FTP。

除非您安装某种 FTP UI 插件(或 Java/Flash 应用程序),或者只是将 FTP 公开给用户,否则您将无法规避此问题。

POST is HTTP, and so are forms. HTTP is not FTP.

Unless you install some sort of FTP UI plugin (or Java/Flash app), or simply expose the FTP to the users, you're not going to be able to circumvent this.

香草可樂 2024-12-27 12:55:01

不,除了精确编辑这两个 php.ini 设置之外,没有其他方法。

No, there is no other way than editing exactly those two php.ini settings.

十雾 2024-12-27 12:55:01

如果您确实需要一种方法并且无法更改 upload_max_filesize,请让您的用户将文件分割成 2M 以下的部分。您可以在服务器上加入他们。
也许您可以向用户显示已上传部分的列表。每当用户上传所有部分时,他单击“所有部分上传”,然后服务器将它们加入。

If you really need a way and cannot change upload_max_filesize, let your users split the file up into parts below 2M. You can join them on the server.
Maybe you could show the users a list of the uploaded parts. Whenever the user uploaded all parts, he clicks "All parts uploaded" and then the server joins them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文