upload icon indicating copy to clipboard operation
upload copied to clipboard

Uploading files of this type is not allowed

Open lhunath opened this issue 3 years ago • 9 comments

Not sure why – but when I try to upload an image, the extension says: Uploading files of this type is not allowed

The image in question:

-rw-r--r--@ 1 lhunath  staff   115K  1 Mar 17:09 /Users/lhunath/Downloads/banner.jpg
$ file --mime-type /Users/lhunath/Downloads/banner.jpg
/Users/lhunath/Downloads/banner.jpg: image/jpeg
$ file /Users/lhunath/Downloads/banner.jpg
/Users/lhunath/Downloads/banner.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 72x72, segment length 16, Exif Standard: [TIFF image data, big-endian, direntries=4, PhotometricIntepretation=RGB, orientation=upper-left, resolutionunit=2], baseline, precision 8, 1170x572, components 3

The image is smaller than my upload limit.

I've tried changing the mime type configuration:

  • ^image/.*
  • (video\/(3gpp|mp4|mpeg|quicktime|webm))|(audio\/(aiff|midi|mpeg|mp4))|(image\/(gif|jpeg|png))|(application\/(x-(7z|rar|zip)-compressed|zip|arj|x-(bzip2|gzip|lha|stuffit|tar)|pdf))
  • .*
  • *

Not sure what's going on.

FWIW: I'm using freeflarum.com

lhunath avatar Mar 02 '21 00:03 lhunath

FYI, there is nothing in the server logs regarding this issue as reported by freeflarum.com (see https://github.com/gwillem/freeflarum.com/issues/195). That likely leaves the extension itself to be the culprit.

lhunath avatar Mar 02 '21 03:03 lhunath

I would rather instead want an option to allow any file type

ghost avatar Apr 15 '21 23:04 ghost

I am having the same issue when pasting an image directly from the clipboard.

image

See also this video: https://drive.google.com/file/u/2/d/1cwE_Qi9XG1ei55v0OOgu9M8_PnSNSjoi/view

orschiro avatar Jan 03 '22 14:01 orschiro

Anyone can fix this case? me get this error too

HideCM avatar Jul 02 '22 15:07 HideCM

This is always an issue with your regex or a different mimetype.

  • Use an online preg match tester like https://regex101.com/ to confirm the regex works
  • Use an online mimetype tester like https://www.htmlstrip.com/mime-file-type-checker to test the actual mime type

luceos avatar Jul 03 '22 10:07 luceos

@luceos if you'd like to ignore this issue, as maintainer of the project, feel free, of course. Though with that said, your justification for closing this issue does not live up to the details of the issue; which means that you are likely only turning a blind eye to a real bug in the code.

Consider that in the OP, https://github.com/FriendsOfFlarum/upload/issues/269#issue-819431975, the regular expression patterns tried are perfectly valid regex, some even in the BRE language superset and furthermore, the image in question has had its mime-type tested (using file) to ensure it was indeed recognized as an image.

Far be it from me to judge how you deal with issues that have been open for a long time, but if you want to just get rid of it, simply closing the GitHub issue without addressing the underlying concern is likely to just result in future complaints or an unstable extension.

lhunath avatar Jul 03 '22 16:07 lhunath

If others can upload jpegs with this extension just fine, it is most likely a regex or server configuration thing.

I'd love to help dive into this, by the way.

So please provide the image in question if this is specific to one image, provide the PHP information, including gd version and a screenshot of the fof upload regex and adapter in use.

luceos avatar Jul 03 '22 17:07 luceos

Use the "Test file MIME type" tool accessible below the MIME configuration in the admin panel to inspect the file using the same libraries that FoF Upload will use against actual uploads. That tool is available since version 1.2.0 of the extension. You can share a screenshot of the output with us.

The test tool can't help with pasted files directly, you would have to save the paste data to a binary file first, then upload that file.

If allowing all MIME types doesn't solve it, it's possible the file contains some "magic" numbers that identify it as an executable file that's blacklisted completely.

*

This likely won't do anything useful in a regular expression. It'll just match the character * since there's no character before it to modify. . is the match-any-single character in a regular expression. * is the zero to many modifier.

clarkwinkelmann avatar Jul 03 '22 19:07 clarkwinkelmann

I'm still getting this error.... no solution?

aggrovated avatar Jul 19 '23 03:07 aggrovated