在 WordPress 主题内使用 .htaccess 定义 php.ini 路径以更改 upload_file_size?

发布于 2024-09-17 23:45:48 字数 801 浏览 1 评论 0原文

我有一个 WordPress 博客。我制作了一个自定义页面模板,允许用户将文件上传到我的服务器。只是一个简单的 php 脚本,它通过一个表单连接到我的服务器来选择文件,blabla.. 你知道!

然而,当 max_upload_filesize 为 20mb 时,上传功能没有任何意义。 现在我想改变这一点。根据我的托管提供商的说法,这确实很容易,但我认为对于没有该领域经验的普通人来说,情况并非如此。不管怎样......

他们告诉我我应该创建一个 .htaccess 文件来存放我的上传脚本。所以它实际上在我的 wordpess 主题文件夹中。

在 .htaccess 文件中,我应该放置“suPHP_ConfigPath”和该目录的路径。

所以在我的情况下,这将是:(至少我认为这是路径)

suPHP_ConfigPath /clientdata/n5200-2-dynamic/a/l/mydomain.com/www/wp-content/themes/mytheme/

此外,我应该在同一目录中创建一个 php.ini 文件,上面写着:

upload_max_filesize = 500M ;
post_max_size = 500M ;

我做了所有这些,甚至在同一目录中创建了一个 info.php 文件检查这东西是否有效。然而 php_info 仍然告诉我上传大小设置为 20mb。

我在这里有什么错吗?你们知道我做错了什么吗? 在这种情况下 php_info 是否告诉我真相并且脚本应该正常工作?或者 php_info 应该告诉我大小设置为我更改的值?

I have a wordpress blog. I made a custom page-template that allows users to upload files to my server. Just a simple php script which connects to my server with a form to select a file, blabla.. you know!

However the upload-feature doesn't make any sense with a max_upload_filesize of 20mb.
Now i want to change that. According to my hosting-provider it's REALLY EASY, but i think for normal people without experience in that field it's not. Anyway...

they told me i should create a .htaccess file where my upload-script is housed. So that's actually in my wordpess theme folder.

in the .htaccess file i should place "suPHP_ConfigPath" and the path to this directory.

so in my case this would be: (at least i think that's the path)

suPHP_ConfigPath /clientdata/n5200-2-dynamic/a/l/mydomain.com/www/wp-content/themes/mytheme/

Moreover i should create a php.ini file in the same directory that says:

upload_max_filesize = 500M ;
post_max_size = 500M ;

I did all of that and even created a info.php file in the same directory to check if the thing worked. However the php_info tells me still that the upload-size is set to 20mb.

Did I get anything wrong here? Do you guys have an idea what I'm doing wrong?
Does the php_info in that case even tell me the truth and the script should normally work? or should the php_info tell me that the size is set to the value I changed it to?

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

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

发布评论

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

评论(2

海未深 2024-09-24 23:45:48

首先,在主题文件夹中创建一个test.php文件并将其放入其中;

<?php
    phpinfo();
?>

在 a 中运行 http://mydomain.com/.../test.php浏览器并在页面上找到“配置文件路径”。如果它与您在 .htaccess 中提到的不匹配,则 .htaccess 无法工作。验证 .htaccess 文件的名称,并首先确保 .htaccess 确实正常工作。如果没有,请致电您的托管支持人员来帮助您。

如果配置路径显示为您在 .htaccess 中指定的路径,则
尝试将这些行也放入 .htaccess 文件中,看看它是否有效。

php_value upload_max_filesize "500000"
php_value post_max_size "500000"

如果 htaccess 正常工作,还可以尝试将 php.ini 中的数字值更改为 500000,而不是 500M。

我希望你的问题很快得到解决。

First of all, create a test.php file in the theme folder and put this into it;

<?php
    phpinfo();
?>

Run http://mydomain.com/.../test.php in a browser and find 'Configuration File Path' on the page. If it does not match the one you mentioned in .htaccess, then the .htaccess is not working. Verify the name of .htaccess file and first make sure .htaccess is actually working first. If not, call your hosting support to help you out.

If the configuration path is showing as the one you specified in .htaccess, then
try putting these lines in the .htaccess file also and see if it works.

php_value upload_max_filesize "500000"
php_value post_max_size "500000"

If htaccess is working, also trying changing the value of the numbers in php.ini to 500000, instead of 500M.

I Hope your problem gets solved soon.

草莓酥 2024-09-24 23:45:48
php_value upload_max_filesize 500000000
php_value post_max_size 500000000

而不是你放在那里的那个非常奇怪的东西

但是,它只能与 Apache mod_php 一起使用

php_value upload_max_filesize 500000000
php_value post_max_size 500000000

instead of that very strange thing you put there

However, it would work only with Apache mod_php

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