Home Forums ACF PRO Image upload size limit on front-end form


Image upload size limit on front-end form

  • Hi

    I have a front-end form that creates a new ‘pending/draft’ post. I’m asking visitors to submit images via the front-end form with a maximum file size of 5mb. I’ve overridden the default WordPress upload limit to 5mb which works for me when I’m logged in as an admin, but when I log out the front-end form still won’t let visitors upload an image that is more than 2mb.

    In the image field settings I also have the Maximum file size set to 5mb.

    Here’s my code in the functions file:

    function my_pre_save_post( $post_id )
        // check if this is to be a new post
        if( $post_id != 'new' )
            return $post_id;
        // Create a new post
        $post = array(
            'post_status'  => 'pending' ,
         // 'post_title' => 'A title, maybe a $_POST variable',
             'post_title' => $_POST['acf']['field_55c9d6feda3a7'],
            'post_type'  => 'interpreted'
        // insert the post
        $post_id = wp_insert_post( $post );
        // update $_POST['return']
        $_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );
        // return the new ID
        return $post_id;
    add_filter('acf/pre_save_post' , 'my_pre_save_post' );

    And the form code:

    	$args = array(
    		'post_id' => 'new',
    		'field_groups' => array(233, 160),
    		'form' => true,
    		'submit_value' => 'Submit Entry',
    		'html_after_fields' => '<input type="hidden" name="post_type" value="cab_submission">',
    		'return' => '',
    		'form_attributes' => array(
         		'enctype' => 'multipart/form-data',
         		'autocomplete' => 'false'
    			acf_form( $args );
  • Problem solved! Because the image field settings already specified ‘MB’ at the end of the field, I was only inserting the numerical value, whereas it actually needs the mb repeating – 5mb not just the 5.

    Hopefully this might help out someone else.

  • More than likely you’ll need to alter the image size limit (upload_max_filesize) on the server php.ini settings. It will depend on your hosting environment exactly how you do that.

  • I may have found a WP filter that will let you change the upload limit

  • Heh, and you figured it out while I was looking. Thanks for sharing.

  • No worries, such a silly gotcha. I wonder if that could be clearer or added to the docs somewhere.

Viewing 6 posts - 1 through 6 (of 6 total)

The topic ‘Image upload size limit on front-end form’ is closed to new replies.