Samarth Agarwal Samarth Agarwal - 1 year ago 88
PHP Question

increase max upload limit in 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
by creating a new file and then opening it in my browser and found this.

Configuration File (php.ini) Path

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.

Answer Source

Try with the following plugin:

/* 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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download