Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

increase max upload limit in wordpress

Tags:

php

wordpress

I need to upload a PDF file to my wordpress site. When I go to Upload New Media, and try uploading it, it says

FileName.pdf exceeds the maximum upload size for this site.

I tried looking for my php.ini file but could not find it. I ran phpinfo() by creating a new file and then opening it in my browser and found this.

Configuration File (php.ini) Path 
C:\Windows

Loaded Configuration File 
C:\Program Files (x86)\Parallels\Plesk\Additional\PleskPHP5\php.ini

I placed a php.ini files with

upload_max_filesize = 512M
post_max_size = 512M
max_execution_time = 300

in wp-admin, httpdocs and everywhere I had access, nothing worked The max upload file size is just 8 MB. Please help me, My client needs to upload that file.

Note: Please don't tell me to restart server, as I can't, It is a hosted site.

like image 461
Samarth Agarwal Avatar asked Nov 27 '22 14:11

Samarth Agarwal


1 Answers

Try with the following plugin:

<?php
/* Plugin Name: Increase Upload Limit */

add_filter( 'upload_size_limit', 'b5f_increase_upload' );

function b5f_increase_upload( $bytes )
{
    return 33554432; // 32 megabytes
}

I built this code based on the following core function:

function wp_max_upload_size() {
    $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) );
    $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) );
    $bytes   = apply_filters( 'upload_size_limit', min( $u_bytes, $p_bytes ), $u_bytes, $p_bytes );
    return $bytes;
}

Another option is upload via FTP and use the plugin Add from Server.

like image 106
brasofilo Avatar answered Dec 10 '22 03:12

brasofilo