PHP version: 8.2.6
Joomla version: 4.2.8
After upgrading to Joomla 4.2 (a while ago) I've gotten complaints from users that they are unable to upload PDF files in the Media library.
Upon some investigation it turns out that Joomla assumes that any file a user uploads is an image, and fails to get the Mime Type for the uploaded file, as it's not an image.
Upon investigation it turns out that this line of code is causing the issue:
The whitelist a bit above that line will also cause Joomla to think that document files are images:
I have to admit that I'm not familiar enough to know if this is a mistake on my part, but changing line 277 to the following resolved my issue:
$mime = static::getMimeType($file['tmp_name'], static::isImage($file['tmp_name']));
Labels |
Added:
No Code Attached Yet
|
The file is listed as Mime Type: "application/pdf" and extension: "pdf"
pdf is configured as a legal document extension, and application/pdf is configured as a legal mime type.
I am not able to reproduce it with v4.3.4. Maybe you can test with a separate clean installation using the latest version.
Labels |
Added:
Information Required
|
Can you please share your media manager options? I suspect that you've followed some wrong tutorial or you have some plugin that is really bad (assigns pdf to images)...
@brianteeman The error states that the file uploaded is not a valid image, Fileinfo Available displays Yes.
@dgrammatiko
Maximum Size (MB): 15
Path to files: images
Path to images: images
Restrict uploads: Yes
Allowed extensions: bmp,gif,jpg,jpeg,png,webp,ico,mp3,mp4,odg,odp,ods,odt,pdf,png,ppt,txt,xcf,xls,csv,doc,docx,xlsx,pptx,dotx,zip
Check MIME-types: Yes
Allowed image extensions: bmp,gif,jpg,png
Legal Audio Extensions: mp3,m4a,mp4a,ogg
Legal Video Extensions: mp4,mp4v,mpeg,mov,webm
Legal Document Extensions: doc,odg,odp,ods,odt,pdf,ppt,txt,xcf,xls,csv,docx,xlsx,pptx,zip,dotx
Illegal extensions: blank
Allowed MIME-types:
image/jpeg,image/gif,image/png,image/bmp,application/x-shockwave-flash,
application/msword,application/excel,application/pdf,application/powerpoint,
text/plain,application/x-zip,application/vnd.openxmlformats-officedocument.wordprocessingml.document,
application/vnd.openxmlformats-officedocument.wordprocessingml.template,application/vnd.ms-word.document.macroEnabled.12,
application/vnd.ms-word.template.macroEnabled.12,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,
application/vnd.openxmlformats-officedocument.spreadsheetml.template,application/vnd.openxmlformats-officedocument.presentationml.presentation,
application/vnd.openxmlformats-officedocument.presentationml.slideshow,video/mp4,
application/zip,application/x-7z-compressed,application/zip-compressed,application/x-zip-compressed,
application/octet-stream,multipart/x-zip,application/x-compress,application/x-compressed
Forbidden MIME-types: text/html
I am not sure if this is relevant here. I cannot upload pdfs. I have a very similar problem with [https://forum.joomla.org/viewtopic.php?t=1002182]
However i found an error in the console.
/administrator/index.php?option=com_media&format=json&mediatypes=0,1,2,3&task=api.files&path=local-images:/content/pdfs/2023](administrator/index.php?option=com_media&format=json&mediatypes=0,1,2,3&task=api.files&path=local-images%3A%2Fcontent%2Fpdfs%2F2023
[HTTP/1.1 403 Forbidden 1332ms]
the http headers plugin is disabled.
If you think is relevant here i can add more info.
Tje strange thing is that when i worked this site in a development server file uploading worked !
Labels |
Added:
bug
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2024-04-24 13:13:35 |
Closed_By | ⇒ | richard67 |
Under Media, select one of these PDFs and click the
i
icon. What is its mime type? Make sure it is listed inLegal MIME Types
under the Media settings.This is better posted @ https://forum.joomla.org/ as it appears to be a support question specific to your setup.