Supergrobi
Member
Uploading images from another server via HTTP often fails with "Oops - Uploaded file is too large", even if the file being fetched doesn't exceed maximum file size.
How to replicate?
What did I test?
I looked into the source code at src/XF/Http/Upload.php in line 560 which is the line throwing the error. I replaced the XF phrase with 'fSize: ' . $this->fileSize . ' - maxFSize: ' . $this->maxFileSize which revealed that the 200kB file "expanded" to over 3MB after upload, throwing the "too large" error. I repeated the test with various other image files with the same results, the file sizes somehow were always at least ten times bigger than the original file I tried to fetch.
Setup
Edit:
Forgot to mention that uploading from the client works without issues. If the image is too large (dimensions) it is resized automatically regarding the numbers in attachments settings. This only happens when uploading from a URL via HTTP.
How to replicate?
- Set a maximum file size of e.g. 2000kB in admin panel under Options -> Attachments -> Maximum attachment file size
- Open a website containing an image you want to attach to the post (not to insert as img tag), e.g. https://i.redd.it/q73rqtpz0vy41.jpg (which is around 200kB)
- Right click image and select "Copy image" (to copy the image data, not the URL)
- Switch to XenForo text editor (posting, private communication, whatever)
- Either right click -> Paste or click into text area and hit Ctrl+V
What did I test?
I looked into the source code at src/XF/Http/Upload.php in line 560 which is the line throwing the error. I replaced the XF phrase with 'fSize: ' . $this->fileSize . ' - maxFSize: ' . $this->maxFileSize which revealed that the 200kB file "expanded" to over 3MB after upload, throwing the "too large" error. I repeated the test with various other image files with the same results, the file sizes somehow were always at least ten times bigger than the original file I tried to fetch.
Setup
- PHP 7.4.16
- XenForo 2.2.5
- No add-ons
Edit:
Forgot to mention that uploading from the client works without issues. If the image is too large (dimensions) it is resized automatically regarding the numbers in attachments settings. This only happens when uploading from a URL via HTTP.
Last edited: