Jump to content

Featured Replies

Posted

We can't figure this one out. The error occurs sometimes when a member attempts to upload an image. I just tested uploading images and could not trigger the error.

Here's one example from the System Log

07/20/2023 01:37 PM upload_failure InvalidArgumentException (0)

#0 /home3/ultravio/public_html/content/system/File/File.php(326): IPS\_Image::create('')
#1 /home3/ultravio/public_html/content/system/File/File.php(436): IPS\_File::create('core_Attachment', '20190624_Rothen...', '', NULL, false, NULL, true)
#2 /home3/ultravio/public_html/content/system/Helpers/Form/Upload.php(755): IPS\_File::createFromUploads('core_Attachment', NULL, NULL, NULL, NULL, 0, Object(Closure), NULL, true)
#3 /home3/ultravio/public_html/content/system/Helpers/Form/Upload.php(309): IPS\Helpers\Form\_Upload->processUploads()
#4 /home3/ultravio/public_html/content/system/Helpers/Form/Editor.php(766): IPS\Helpers\Form\_Upload->__construct('topic_comment_5...', Array, false, Array)
#5 /home3/ultravio/public_html/content/system/Helpers/Form/Editor.php(185): IPS\Helpers\Form\_Editor->getUploader('topic_comment_5...')
#6 /home3/ultravio/public_html/content/system/Content/Item.php(5072): IPS\Helpers\Form\_Editor->__construct('topic_comment_5...', NULL, true, Array, Object(Closure))
#7 /home3/ultravio/public_html/content/system/Content/Item.php(4749): IPS\Content\_Item->commentFormElements()
#8 /home3/ultravio/public_html/content/system/Theme/Theme.php(885) : eval()'d code(5312): IPS\Content\_Item->commentForm()
#9 /home3/ultravio/public_html/content/system/Theme/SandboxedTemplate.php(61): IPS\Theme\class_forums_front_topics->topic(Object(IPS\forums\Topic), Array, NULL, Array, true, NULL, Array)
#10 /home3/ultravio/public_html/content/applications/forums/modules/front/forums/topic.php(611): IPS\Theme\_SandboxedTemplate->__call('topic', Array)
#11 /home3/ultravio/public_html/content/system/Dispatcher/Controller.php(118): IPS\forums\modules\front\forums\_topic->manage()
#12 /home3/ultravio/public_html/content/system/Content/Controller.php(50): IPS\Dispatcher\_Controller->execute()
#13 /home3/ultravio/public_html/content/applications/forums/modules/front/forums/topic.php(39): IPS\Content\_Controller->execute()
#14 /home3/ultravio/public_html/content/system/Dispatcher/Dispatcher.php(153): IPS\forums\modules\front\forums\_topic->execute()
#15 /home3/ultravio/public_html/content/index.php(13): IPS\_Dispatcher->run()
#16 {main}

 

Solved by annedi

Go to solution

I would need to know exactly what is being uploaded, so I can test on this end and see what is going on there for you.

  • Author

It was a member's jpg image. I cannot supply that particular image because it did not upload and the member gave up. 

I tried uploading a jpg, jpeg, bmp and gif with no problems. I'm wondering if there was some kind of "traffic" problem at that particular time?

((I've learned so much about running a website from this forum. Nice.))

  • Author

Could unusual characters in a filename cause an upload problem? I have warned against this in the past. I tested some uploads of files named like DSC+-#$%.jpg and had no problem. I did not test every possible unusual character.

The log suggests the image was an empty file

  • Author

Well that's strange! Which line in the quoted system log tells you that, please?

I'll ask the members who experienced the failed upload if somehow the file they tried to upload was empty. Will report back.

  • Author

I just now was able to induce an image upload_failure. I tried to upload a JPG image from a Bushnell Trail Cam. It was a 2.6MB file with pixel dimensions 1888x1062.

And, as you can see, that image file uploaded quite nicely here. 

Could contain: Animal, Mammal, Rat, Rodent, Pebble, Road, Plant, Fox, Kit Fox, Wildlife

 

So I'm thinking that I have either a server problem (but why I cannot guess) or some kind of configuration problem. I have looked at our settings thru Admin and see that I have no restrictions on size of image uploads. So I'm still baffled why this image uploads here but not on my forum.

  • Author

Here are our image size settings. No restrictions.

Could contain: Page, Text, File

 

HOWEVER, I could not upload the rabbit image (shown above) until I reduced it to 800 pixels on the long side. Then it finally uploaded OK. Confusion.

Would guess by it being an empty file that the file either was not passed along or intercepted. If you have CloudFlare or something sitting in front, you would want to try disabling that. Also, if you have any third party applications/plugins/themes, disabling those will also help rule them out from causing an issue here.

16 minutes ago, annedi said:

Here are our image size settings. No restrictions.

 

  • Author

Yes, perhaps we should set limits on image dimensions and file size, but the fact is that we do not have that restriction in place.

However I have discovered that when the image dimensions are larger than a max 1400 pixels, we get an upload error. Where is that being enforced? In the past we have had successful uploads of images larger than 1400 pix maximum width. It's not making sense to suddenly encounter a restriction on image size. 

  • Author

Here are some test results. They seem to be rather random. I am getting upload failures both when image dimension restrictions are in place and when they are not.

Image dimension maximum set to 1200 pixels.
1) Upload 7360 x 4912 JPG. Success. Resized to 1200 px width.
2) Upload 7360 x 4912 JPG. FAIL.
3) Upload 2551 x 2099 JPG. Success. Resized to 1200 px width.
4) Upload 5504 x 5504 JPG. FAIL.

Image dimensions unrestricted.
1) Upload 1400 x 934 JPG. Success.
2) Upload 7360 x 4912 JPG. FAIL.
3) Upload 3680 x 2456 PNG. Success.
4) Upload 1600 x 812 JPG. Success.
5) Upload 1998 x 1416. Success.

 

We have no 3rd party apps. We do not have CloudFlare.

Edited by annedi

  • Author

So far there are no upload failures with the Invalid Argument Exception when a PNG image is uploaded. The upload failures only happen with JPG images.

do you have the ImageMagick or GM extension on your server?

try changing the image quality to a lower one

  • Author

Thank you for the suggestion. I have re-set ImageMagick down to 85, and I'll retest with that setting.

I'm not sure, though, why the ImageMagick extension would suddenly start causing problems?

  • Author

Changing the ImageMagick setting did not help.

Here are some recent upload test results. If there a pattern here, I cannot find it.

JPG, 1400 x 932 px. SUCCESS.
JPG, 1500 x 758 px. SUCCESS.
JPG, 1500 x 1000 px. FAIL.


JPG, 1800 x 1200 px. FAIL.
PNG, 1800 x 1200 px. SUCCESS.

JPG, 2000 x 500 px. SUCCESS
JPG, 500 x 2000. SUCCESS.


JPG, square, 1400 x 1400.  FAIL.
JPG, square, 1800 x 1800. SUCCESS.

I would suggest first of all ruling out imagemagick by switching to GD. This is the only way to really rule it out

  • Author

Switching to GD seems to cure the problem. Whew....I really really hope that turns out to be true. But I need to run with GD for a couple of days to be sure. 

Why in the world would ImageMagick "suddenly" start causing problems? Could it have anything to do with upgrading to PHP 8.whatever?

  • Author

Switching to GD seems to cure the problem. Whew....I really really hope that turns out to be true. But I need to run with GD for a couple of days to be sure. 

Why in the world would ImageMagick "suddenly" start causing problems? Could it have anything to do with upgrading to PHP 8.2.8?

1 hour ago, annedi said:

Could it have anything to do with upgrading to PHP

IPS does not support PHP 8.2! The maximum version is PHP 8.1.

35 minutes ago, SeNioR- said:

IPS does not support PHP 8.2! The maximum version is PHP 8.1.

This would indeed likely be your issue

  • Author

My error:  Our host server is running PHP 8.2.8. The forum software, however, is using PHP 8.1.21. I went to look up PHP versions and cited the wrong one above. Pls excuse me! (It was late.)

Anyway, ImageMagick is having problems under PHP 8.1.21 for our website. The switch to GD seems to be working. Shouldn't they both be usable with 8.1.21?

 

Each version of php can be compiled with different options/flags by your host.  If they did not compile one version correctly it can be a problem. 

Edited by Randy Calvert

6 hours ago, annedi said:

Anyway, ImageMagick is having problems under PHP 8.1.21 for our website. The switch to GD seems to be working. Shouldn't they both be usable with 8.1.21?

Should, but clearly in your case not. Your host would need to look at that for you

  • Author
  • Solution

OK, I think it has all come together now. I'll summarize so that a solution can be declared.

My website began to have sporadic image JPG upload failures. I couldn't completely correlate upload failures with image dimensions or file size, although upload failure did affect mostly large dimension JPGs. We had no problem with PNG uploads of any size.

We had been using ImageMagick all along. Lowering the ImageMagick quality setting did not fix the problem. Marc suggested switching to GD. That stopped the JPG upload failures. 

Thinking back, I realized that the upload failures began after the change to PHP 8.1.21. Randy suggested that the host might have missed setting some flag/option to ensure ImageMagick ran properly with PHP 8.1.21. So, as Marc suggested, I will ask my host to fix this PHP/ImageMagick incompatibility.

Thanks to SeNior-, Randy, Jim M and Marc for their useful suggestions and help. 😃

Edited by annedi

Recently Browsing 0

  • No registered users viewing this page.