Notifications
Q&A

Welcome to Codidact Meta!

Codidact Meta is the meta-discussion site for the Codidact community network and the Codidact software. Whether you have bug reports or feature requests, support questions or rule discussions that touch the whole network – this is the site for you.

Unable to upload a picture to answers, questions, etc.

+1
−0

I'm using Mozilla Firefox. When I try to upload a picture to a question or answer, I get the following error:

error: "Images must be one of png, jpeg, jpg, gif"

However, it would be easy to verify whether or not I have the correct file type for the picture. I'm 100% sure that I'm updating the right file type.

When I use the internet browser's inspector tool and attempt to upload a picture, I get the following response:

Status: 400 Bad Request
Version: HTTP/2
Transferred: 1.24 KB (53 B size)

Is anyone else having this issue? Do I need to copy more specific information? (if so, then please elaborate)? Is the token generated by this request not valid?

Why should this post be closed?

6 comments

Operating system? Firefox version? Actual filename (including extension)? Filesize? "I'm 100% sure that I'm updating the right file type" doesn't say what the file type is. ‭manassehkatz‭ about 1 month ago

@manassehkatz I've tried this on other internet browsers like Microsoft Edge and Internet Explorer (so the OS is Windows 10). Same results. Using the latest version of Firefox (no beta builds). Picture is a 14kB .jpg file. File name was "Capture.jpg" because I was simply using the snipping tool and that's the default name when you save an image. ‭KingDuken‭ about 1 month ago

That is very strange with an actual .jpg extension. ‭manassehkatz‭ about 1 month ago

Send me the image you're trying to upload? [email protected] should work. ‭‮edoCfOtrA‭ about 1 month ago

Are you having problems with all uploads or just this one (or is this the only one you've tried so far)? ‭Monica Cellio‭ about 1 month ago

Show 1 more comments

1 answer

+1
−0

OK. This appears to be a variant of the known image issues. Specifically, it is relying on extension to determine image type, rather than doing an analysis after upload.

However, it appears that SomeOther sites do something very similar, so this is far from a uniquely Codidact problem.

The problem is a bit of a tricky one. Limiting based on extension is a time-honored technique to help filter bad (or just useless) files. On the other hand, it is no guarantee that the files are what they say they are - e.g., an executable masquerading as an image. The solution to that problem is to a check after upload to make sure the content nominally matches the stated filetype.

Until we get a far more sophisticated image upload process, I think this will stay "as is" - but others may be willing to tackle it, so we'll see.

3 comments

This isn't correct. Yes, we check extension, but we also analyse the image itself - check its content type, and process the image to check its file format matches what we're expecting. If an image is rejected, it can be because of the extension, but since that's clearly correct it's obviously failing one of the other checks. ‭‮edoCfOtrA‭ about 1 month ago

I'm a bit confused @ArtOfCode so please confirm or correct: It sounds like you are saying that first extension is checked and second internal file format is verified. The end result would be: If a file has no extension (or a non-image extension) then it will be rejected by the first test, and if it doesn't match (e.g., .jpg but file doesn't match the standard .jpg format) then it gets rejected by the second test. I think that matches what I see in practice, but could cause problems ‭manassehkatz‭ about 1 month ago

for people who upload with no extension or wrong extension. While I originally thought that was OP's problem, later comments seem to indicate that is not the case (e.g., "capture.jpg" should work). ‭manassehkatz‭ about 1 month ago

Sign up to answer this question »