简体   繁体   中英

I am unable to upload media files larger than 8MB in wordpress

I am hosting this site through Microsoft Azure.

I just tried to append define('WP_MEMORY_LIMIT', '3000M'); into the wp-config.php file and that did not work.

I have tried to add a php.ini file into the root directory with no success. I also attempted to move that file into the wp-admin directory and then attempted the same thing in both directories with the file name php5.ini and nothing will work.

I tried adding the following code to the theme functions.php file (with no success):

@ini_set( 'upload_max_size' , '64M' );
@ini_set( 'post_max_size', '64M');
@ini_set( 'max_execution_time', '300' );

The ONLY other solution I have seen that I haven't been able to try is editing the .htaccess file. Where is that thing?! I've looked all through the source and just cannot find it. Also, what is the file NAME? Every post I've found has referred to it as "the .htaccess file" but I see nothing with that file type and cannot create one since I do not know what the actual NAME of the file should be.

Any help or other solutions would be much appreciated.

You can't create a php.ini file and your .htaccess is in your wordpress folder. if you haven't enabled premalink under wordpress admin panel it doesn't create the file. after you have the .htaccess file you'll need to make sure to set AllowOverride to All instead of None in your web server configuration and enable mod_rewrite so it reads the .htaccess file. What Linux distribution are you running on your server? is this a windows server? what is the last error_log for uploading images on your web server? it gives you better idea of what's throwing the error. Is this IIS or Apache ?

By default on Azure, the upload_max_filesize is set to 8M, we can change the built-in PHP configurations to enlarge it.

Here are the steps:

1, Add a .user.ini file to your root directory.

2, Add configuration settings to the .user.ini file using the same syntax you would use in a php.ini file. With your demand, your .user.ini file would contain this text:

upload_max_filesize = 20M
; Maximum size of POST data that PHP will accept.
post_max_size = 20M
max_execution_time = 300

3, Deploy your web app.

4, Restart the web app.

You can read official guide for more information.

By the way, we can use FTP tool to connect your Azure Web sites server to create and modify the custom configuration file instead of redeploying the project.

The default root directory is D:\\home\\site\\wwwroot .

<configuration>
 <system.webServer>
  <security>
     <requestFiltering>
        <requestLimits maxAllowedContentLength="<valueInBytes>"/>
     </requestFiltering>
  </security>
 </system.webServer>
 </configuration>

For more information, please check this reference: https://blogs.msdn.microsoft.com/azureossds/2016/06/15/uploading-large-files-to-azure-web-apps/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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