Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Image not uploading within posts

odannycodannyc New
edited March 2016 in Vanilla 2.0 - 2.8

When I try and upload an image via the text editor, whether I'm creating new discussions or adding comments I get this error: "(image.jpg) is too large (max false bytes)."

Any help is greatly appreciated. Thanks.

Tagged:

Comments

  • Options

    Have you tried a variety of pictures? Where is the error originating from (Chrome developer tools, Vanilla debug log, etc)?

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    Have you set enough size in config.php?

    $Configuration['Garden']['Upload']['MaxFileSize'] = '64M';

    And also check with host what is the maximum. Most hosts allow 64MB max....

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    Also : see this config

    $Configuration['Garden']['Picture']['MaxHeight']                = 1000;
    $Configuration['Garden']['Picture']['MaxWidth']                 = 600;
    
  • Options

    Hey thanks for the replies. I've tried with all kinds of images, small, big, all types of extensions to no avail.
    One thing I did notice is that using the ImageUpload plugin everything works fine, but not the native picture upload in the advanced editor.

  • Options

    @odannyc could you post a screenshot of the error (and backtrace if available)?

  • Options
    noncenonce Necro-on Forensics
    edited March 2016

    you said: I get this error: "(image.jpg) is too large (max false bytes)."

    see the Tutorials in the category Tutorials! look at the Code!

    I read the tutorials, and looked through the code.

    looking at the editor plugin php code you will see

      // Set variables for file uploads
        $PostMaxSize = Gdn_Upload::unformatFileSize(ini_get('post_max_size'));
        $FileMaxSize = Gdn_Upload::unformatFileSize(ini_get('upload_max_filesize'));
        $ConfigMaxSize = Gdn_Upload::unformatFileSize(c('Garden.Upload.MaxFileSize', '1MB'));
        $MaxSize = min($PostMaxSize, $FileMaxSize, $ConfigMaxSize);
        $c->addDefinition('maxUploadSize', $MaxSize);
       // Set file input name
        $c->addDefinition('editorFileInputName', $this->editorFileInputName);
        $Sender->setData('_editorFileInputName', $this->editorFileInputName);
       // Save allowed file types
        $c->addDefinition('allowedFileExtensions', json_encode(c('Garden.Upload.AllowedFileExtensions')));
       // Get max file uploads, to be used for max drops at once.
        $c->addDefinition('maxFileUploads', ini_get('max_file_uploads'));
       // Set canUpload definition here, but not Data (set in BeforeBodyBox) because it overwrites.
        $c->addDefinition('canUpload', $this->canUpload);
    }
    

    three variables affect upload ability.

    the two ini get statements are pulling info from your php settings.
    to determine your php settings - use phpinfo and look for upload_max_filesize and 'post_max_size
    lucky you are - there are tutorials on how to use phpinfo. where? in the tutorials category.
    the

    c('Garden.Upload.MaxFileSize', '1MB') says if you have a config statment relating to Garden Upload MaxFileSize
    it will use that number otherwise it will default to 1MB.

    next $MaxSize = min($PostMaxSize, $FileMaxSize, $ConfigMaxSize);

    the minimum size of the upload_max_filesize and 'post_max_size and Garden Upload MaxFileSize is selected.

    you could add a decho or echo or var_dump after this line. to determine the value of $MaxSize.

    next $c->addDefinition('maxUploadSize', $MaxSize) adds the definition so the js can use the values.

    next look at Garden.Upload.AllowedFileExtensions if the extensions are not allowed you can't upload extensions.

    now lets look at the js.

    var maxUploadSize = gdn.definition('maxUploadSize');

    you could console.log the value in console for maxUploadSize.
    once again Tutorials available of for use console - firebug, Chrome, etc.

    here is the error mesage you received:in the editor.js

    message += 'is too large (max ' + maxUploadSize + ' bytes)';

    you stated. I get this error: "(image.jpg) is too large (max false bytes)."

    max false bytes

    if looks like maxUploadSize is false. in your case? Why?

    how do we debug this?
    by the standard troubleshooting protocol. see the Tutorial category for a discussion on this.
    check your config statements. test with default theme. disable other plugins. enable editor plugin.
    WSIWYG has some peculiarities. test with a different input format. see Tutorials for input format.

    how can you see the values that available for js added definitions. one way is to use the console.

    in chrome type f12 . click console. then type in gdn.meta. you will see a list of items in the object.

    use the arrows. and you will see for vanilla forums all of the meta variables
    including this one.
    maxUploadSize: 52428800

    you could also use alert and console logging of the object source but this is the easiest.

    troubleshooting steps. does upload work with default theme and all plugins but the advanced editor plugin disabled.
    provide your configuration statements regarding file size and uploads and extensions and what extensions and exact sizes you tried. provide any attempts at code debugging via echo, etc. screenshot of gdn.meta with console.
    do you see any js errors in console?

  • Options
    noncenonce Necro-on Forensics
    edited March 2016

    my guess you have a js error without further input from you.

    with your testing and answers, it should be easy to determine the issue.

    is the problem across all types of browsers or browser specific? Do all users have same problem?

    what are the values?

    does the file Already Exist? then we would expect this message += 'is already in this discussion. It will not be uploaded again';

    validSize is set to TRUE or FALSE here...

     var validSize = (file.size <= maxUploadSize)
                                    ? true
                                    : false;
    

    why is validSize False?

    but why is MaxUploadSize false - js error??? if MaxUploadSize had a value - we would expect the size in bytes to be given.

     if (validSize && validFile && !fileAlreadyExists) {
                                    data.submit();
    
                                    // If selecting a file through traditional file
                                    // input, close the dropdown.
                                    editorDropdownsClose();
                                } else {
                                    // File dropped is not allowed!
                                    var message = '"' + filename + '" ';
    
                                    if (!validFile) {
                                        message += 'is not allowed';
                                    }
    
       ----->                   if (!validSize) {
                                        if (!validFile) {
                                            message += ' and ';
                                        }
                                        message += 'is too large (max ' + maxUploadSize + ' bytes)';
                                    }
    
  • Options

    I didn't get anywhere trying to troubleshoot.

    On thing I do need to mention is the exact same code works in my development environment... when I upload a picture through advanced editor there, the picture uploads just fine, but when I do it in my production website it gives me the error, "Max False Bytes", it happens in all browsers, and the image size does not matter.

    At first I thought maybe I didn't have file uploads enabled in my server but I do. Another thing that throws me off is that I can upload pictures through the FileUpload plugin just fine, but not the advanced editor part.

    Again, this works on my development machine (XAMPP) , but not production.

  • Options
    odannycodannyc New
    edited March 2016

    Solved. I was using HHVM for production and the ini_get() had different value names than the ones in HHVM.
    I enabled enable_zend_ini_compat in HHVM

Sign In or Register to comment.