简体   繁体   English

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

[英]Define php.ini path with .htaccess inside a Wordpress theme to change upload_file_size?

I have a wordpress blog. 我有一个wordpress博客。 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! 只是一个简单的PHP脚本,它通过一种形式连接到我的服务器以选择一个文件,等等。

However the upload-feature doesn't make any sense with a max_upload_filesize of 20mb. 但是,max_upload_filesize为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. 他们告诉我,我应该在存放我的上传脚本的地方创建一个.htaccess文件。 So that's actually in my wordpess theme folder. 所以这实际上是在我的wordpess主题文件夹中。

in the .htaccess file i should place "suPHP_ConfigPath" and the path to this directory. 在.htaccess文件中,我应该放置“ suPHP_ConfigPath”和此目录的路径。

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: 此外,我应该在表示以下内容的同一目录中创建一个php.ini文件:

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. 我做了所有这些工作,甚至在同一目录中创建了一个info.php文件来检查事情是否正常。 However the php_info tells me still that the upload-size is set to 20mb. 但是php_info仍然告诉我,upload-size设置为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? 在这种情况下,php_info甚至可以告诉我真相并且脚本应该正常工作吗? or should the php_info tell me that the size is set to the value I changed it to? 还是php_info告诉我大小设置为我将其更改为的值?

First of all, create a test.php file in the theme folder and put this into it; 首先,在主题文件夹中创建一个test.php文件,并将其放入其中;

<?php
    phpinfo();
?>

Run http://mydomain.com/.../test.php in a browser and find 'Configuration File Path' on the page. 在浏览器中运行http://mydomain.com/.../test.php ,然后在页面上找到“配置文件路径”。 If it does not match the one you mentioned in .htaccess, then the .htaccess is not working. 如果它与您在.htaccess中提到的不匹配,则说明.htaccess无法正常工作。 Verify the name of .htaccess file and first make sure .htaccess is actually working first. 验证.htaccess文件的名称,然后首先确保.htaccess实际上是首先工作。 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. 如果配置路径显示为您在.htaccess中指定的路径,请尝试将这些行也放入.htaccess文件中,并查看其是否有效。

php_value upload_max_filesize "500000" php_value post_max_size "500000" 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. 如果htaccess有效,还尝试将php.ini中的数字值更改为500000,而不是500M。

I Hope your problem gets solved soon. 希望您的问题能尽快得到解决。

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 但是,它仅适用于Apache mod_php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM