Jimmy Jimmy - 5 months ago 9
PHP Question

WordPress : Change limit of 140 when trying to post forms

I made a simple Wordpress plugin which adds files to users but I hit errors when I try and add more than 139 files to a user.

Is there some sort of built in limits with php, wordpress or even the htaccess file that could be causing this? I say this only because there is nothing in my code to put any limits in place.

This is the bit of code which I believe submits the file upload:

//user porfile fields save
public function save_user_file_upload_fields($user_id) {
if (isset($_POST['bhuufu-user-uploads']['file_url_tmp']) && $extra_fields = array_filter($_POST['bhuufu-user-uploads']['file_url_tmp'])) {
foreach ($extra_fields as $key => $value) {
$_POST['bhuufu-user-uploads']['file_url'][] = $_POST['bhuufu-user-uploads']['file_url_tmp'][$key];
$_POST['bhuufu-user-uploads']['file_name'][] = $_POST['bhuufu-user-uploads']['file_name_tmp'][$key];
$_POST['bhuufu-user-uploads']['file_description'][] = $_POST['bhuufu-user-uploads']['file_description_tmp'][$key];
$_POST['bhuufu-user-uploads']['file_id'][] = $_POST['bhuufu-user-uploads']['file_id_tmp'][$key];
$_POST['bhuufu-user-uploads']['file_oname'][] = $_POST['bhuufu-user-uploads']['file_oname_tmp'][$key];
$_POST['bhuufu-user-uploads']['file_mime'][] = $_POST['bhuufu-user-uploads']['file_mime_tmp'][$key];
}
}


It's all been done with post so I think there maybe an issue with this but I am not sure what. It works perfectly up to this limit.

I've done a bit of searching but Google doesn't bring up anything about any sort of array limits when coming to that specific number and I'm surprised I'm the only one who hit this problem.

Answer

You can check value of max_input_vars & max_input_nesting_level using phpinfo() function. Try to increase those value. When it is set, it limits your number of inputs (that is, fields in your forms).

Above values are configurable. Edit your php.ini or htaccess to update those values.