Can not upload document file PDF "Error Unable to upload file" Topic is solved

General questions relating to Joomla! 4.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
Revo7
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Thu Jan 24, 2008 5:59 pm

Can not upload document file PDF "Error Unable to upload file"

Post by Revo7 » Thu Jan 13, 2022 11:19 pm

Wasted a whole day trying to fix this issue and have found myself frustrated. When in an article using the Tinymce or ARKEditor to add a document link the Joomla 4 Media Manager keeps giving an error of "Error
Unable to upload file."

I have already chatted with my hosting server guy and he was not able to find any issues on the serverside of things. He did however did check the error code and here is what came back:


[Thu Jan 13 11:25:37.265838 2022] [core:error] [pid 9991:tid 47315136202496] [client 123.45.67.890:57013] Script timed out before returning headers: index.php, referer: https://[spam].com/administrator/index.php

With that information, I decided to dig deeper, and Image files upload just fine jpg or png work great, but pdf or any other document type file does not upload. I’ve checked all the normal places in the Joomla admin panels and they are normal. I really think it might be server-side somewhere that is causing this issue. What I question is in the error log it points to the Script timing out before returning headers, which tells me it’s a timing thing, but why would it affect the timing of documents and not images. This is really freaking weird.

max_execution_time :3000
memory_limit: 128M
upload_max_filesize: 86M

Any ideas on how to fix this or can anyone point me in a direction that could solve this as I have gone down now many rabbit trail directions with no avail. Thanks and I'm loving Joomla 4.


Kindest Regards,
JT

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 12474
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: Can not upload document file PDF "Error Unable to upload file"

Post by brian » Thu Jan 13, 2022 11:57 pm

How big is the pdf?
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

Revo7
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Thu Jan 24, 2008 5:59 pm

Re: Can not upload document file PDF "Error Unable to upload file"

Post by Revo7 » Fri Jan 14, 2022 1:54 am

136kb PDF at least I was sampling with and I tried a 19kb excel and a 51kb MS Word. None will upload, but images much bigger will.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 14587
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Can not upload document file PDF "Error Unable to upload file"

Post by toivo » Fri Jan 14, 2022 4:54 am

The error message is displayed if the file cannot be written into a directory.

Check that the folder and Joomla temporary directory are writable from System - System Information - Folder Permissions and check the folder permissions in the server.
Toivo Talikka, Global Moderator

User avatar
ceford
Joomla! Guru
Joomla! Guru
Posts: 727
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: Can not upload document file PDF "Error Unable to upload file"

Post by ceford » Fri Jan 14, 2022 6:46 am

What happens when you use cPanel (or similar) or FTP to upload the pdf directly to the images folder? Can you then select the pdf? Also, check the Media Options - you should see pdf in Allowed Extensions and Legal Document Extensions.

Revo7
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Thu Jan 24, 2008 5:59 pm

Re: Can not upload document file PDF "Error Unable to upload file"

Post by Revo7 » Fri Jan 14, 2022 9:36 pm

I can upload fine through FTP, but when I train my clients on the editor I want them to be able to do that as well clients do not know FTP stuff. They usually are tech-challenged. Once it is in there through FTP then yes a link can be created to it in the editor. PDF and other normal extensions are enabled.

Revo7
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Thu Jan 24, 2008 5:59 pm

Re: Can not upload document file PDF "Error Unable to upload file"

Post by Revo7 » Fri Jan 14, 2022 9:37 pm

toivo wrote:
Fri Jan 14, 2022 4:54 am
The error message is displayed if the file cannot be written into a directory.

Check that the folder and Joomla temporary directory are writable from System - System Information - Folder Permissions and check the folder permissions in the server.
Yes, it is marked writable and is set to 755 permissions.

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 12474
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: Can not upload document file PDF "Error Unable to upload file"

Post by brian » Fri Jan 14, 2022 9:59 pm

In the media manager try changing Check MIME Types to No
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 14587
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Can not upload document file PDF "Error Unable to upload file"

Post by toivo » Fri Jan 14, 2022 10:01 pm

Revo7 wrote:
Thu Jan 13, 2022 11:19 pm
upload_max_filesize: 86M
What is the value of post_max_size in php.ini?

What about the name of the PDF file, does it have any special characters, umlauts (äöå etc) or blank spaces?
Toivo Talikka, Global Moderator

Revo7
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Thu Jan 24, 2008 5:59 pm

Re: Can not upload document file PDF "Error Unable to upload file"

Post by Revo7 » Fri Jan 14, 2022 10:19 pm

@brian Ok I changed that to no and still get the "Unable to upload file." So frustrating...

@tovio the post_max_size: 256M, the name has no spaces or special characters.

I am checking and I am finding the same issue now with all my Joomla 4 sites and my Joomla 3.5. Images upload fine with no issues, but documents like PDF's are a no-go through the editor. I almost wonder if its a PHP code setting within PHP 7.3 and 7.4

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 14587
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Can not upload document file PDF "Error Unable to upload file"

Post by toivo » Fri Jan 14, 2022 10:28 pm

Are the sites hosted in the same server? Does the host use mod_security or some scanning application that blocks those files? Talk to your host.
Toivo Talikka, Global Moderator

Revo7
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Thu Jan 24, 2008 5:59 pm

Re: Can not upload document file PDF "Error Unable to upload file"

Post by Revo7 » Fri Jan 14, 2022 11:22 pm

@toivo yes dedicated servers with the same company for the last 16 years.

User avatar
ceford
Joomla! Guru
Joomla! Guru
Posts: 727
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: Can not upload document file PDF "Error Unable to upload file"

Post by ceford » Sat Jan 15, 2022 12:00 am

How long do you actually have to wait for the error message?

Debugging the Media component is tricky because the upload is handled via Javascript. However, the error message originates on line 219 of libraries/src/Helper/MediaHelper.php. It might be possible to generate a stack trace at that point but it needs to be sent to a log - I don't know how to do that.

Revo7
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Thu Jan 24, 2008 5:59 pm

Re: Can not upload document file PDF "Error Unable to upload file"

Post by Revo7 » Sat Jan 15, 2022 12:40 am

Message is pretty instant. The error log gives same message as the other day: [Thu Jan 13 11:25:37.265838 2022] [core:error] [pid 9991:tid 47315136202496] [client 192.63.74.104:57013] Script timed out before returning headers: index.php, referer: https://xxxxxx.com/administrator/index.php

User avatar
ceford
Joomla! Guru
Joomla! Guru
Posts: 727
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: Can not upload document file PDF "Error Unable to upload file"

Post by ceford » Sat Jan 15, 2022 8:46 am

You have not said, but I assume that uploading a pdf using the Media component directly via the Content / Media menu gives the same result. Stepping through upload with a debugger I see that content plugins are triggered so I wonder what other extensions are in use.

Turns out that the Error Unable to Upload File is also triggered in plugins/filesystem/local/src/Adapter/LocalAdapter.php on line 815 - on creation of a temporary file with a name like images/61e288327715f.pdf

Revo7
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Thu Jan 24, 2008 5:59 pm

Re: Can not upload document file PDF "Error Unable to upload file"

Post by Revo7 » Sun Jan 16, 2022 8:05 pm

Yes, I am using the Media component directly via the Content, the same as my client would. I came across this error in the middle of training a client on how to make document links to a PDF. I get the same error when going straight to the Media manager from the admin menu. I have not uploaded any special plugins outside of the template from Joomla51.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 14587
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Can not upload document file PDF "Error Unable to upload file"

Post by toivo » Sun Jan 16, 2022 8:41 pm

Joomla 4.0.5 allows PDF files to be uploaded from Media perfectly all right. My tests using both Wampserver and remote Linux work all right. This points to the configuration of the server and/or the folder permissions.
Toivo Talikka, Global Moderator

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 28835
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: Can not upload document file PDF "Error Unable to upload file"

Post by Per Yngve Berg » Sun Jan 16, 2022 9:03 pm

Is the Memory Limit -1 on the server?

User avatar
brian
Joomla! Master
Joomla! Master
Posts: 12474
Joined: Fri Aug 12, 2005 7:19 am
Location: Leeds, UK
Contact:

Re: Can not upload document file PDF "Error Unable to upload file"

Post by brian » Sun Jan 16, 2022 9:12 pm

toivo wrote:
Fri Jan 14, 2022 10:28 pm
Talk to your host.
"Exploited yesterday... Hacked tomorrow"
Blog http://brian.teeman.net/
Joomla Hidden Secrets http://hiddenjoomlasecrets.com/

Revo7
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Thu Jan 24, 2008 5:59 pm

Re: Can not upload document file PDF "Error Unable to upload file"

Post by Revo7 » Wed Jan 19, 2022 7:10 pm

brian wrote:
Sun Jan 16, 2022 9:12 pm
toivo wrote:
Fri Jan 14, 2022 10:28 pm
Talk to your host.
You guys were right once I got to a main high-level server engineer. Here is what the issue was explained by the engineer and it made total sense and everything works better than before actually.

"First off you would make sure your Cpanel server has directives in place for its Apache MPM. In your case it's event

I found there were no apache directives"

Basically, I had no directives and I would post them and the settings here, but for obvious reasons, I will not. Hope this helps.

imrodmartin
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Apr 03, 2014 12:51 am

Re: Can not upload document file PDF "Error Unable to upload file"

Post by imrodmartin » Sat Apr 02, 2022 2:22 pm

@revo7
I'm having the same issue on one of my servers... I know you can't publish details about your WHM setup - but can you be more specific about which directives they enabled? I have mod_mpm_worker turned on - but to no avail.

thanks!


Post Reply

Return to “General Questions/New to Joomla! 4.x”