Hello,

I have a new drupal 7.20 installtion.
I created a new content type with a file field.

When I try to create new content and then try to upload a file, I get the following error message:

"An unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (32 MB) that this server supports."

The PHP settings are not the problem:
post_max_size = 128 MB
upload_max_filesize = 32MB

The file size is 40Kb

The file field upload gives me that error when javascript is enabled. But when it is disabled it doesn't give the error message and it also doesn't upload the file. The field remains empty.
The image filed upload is working fine with javascript enabled or disabled.

I googled it and searched the forums. I found that many people had/ has the same problem.

I tried this solution suggested by New Zeal, and it didn't work:

Replacing:

  # Pass all requests not referring directly to files in the filesystem to
  # index.php. Clean URLs are handled in drupal_environment_initialize().
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ index.php [L]

With:

  # Pass all requests not referring directly to files in the filesystem to
  # index.php. Clean URLs are handled in drupal_environment_initialize().
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteCond %{REQUEST_URI} !filefield\/(.*)$
  RewriteCond %{REQUEST_URI} !upload\/(.*)$  
  RewriteRule ^ index.php [L]

Gives the same error.

Replacing:

  # Pass all requests not referring directly to files in the filesystem to
  # index.php. Clean URLs are handled in drupal_environment_initialize().
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ index.php [L]

With:

  # Pass all requests not referring directly to files in the filesystem to
  # index.php. Clean URLs are handled in drupal_environment_initialize().
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
  RewriteCond %{REQUEST_URI} !filefield\/(.*)$
  RewriteCond %{REQUEST_URI} !upload\/(.*)$  
  RewriteRule ^ index.php [L]

Gives another error:

An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /file/ajax/field_medical_files/und/form-q8S9fYI6nipgluJU4sIDNtZElWr8Puacz5-uSRGPYug
StatusText: n/a
ResponseText: Internal Server Error
The server encountered an internal error or
misconfiguration and was unable to complete
your request.
Please contact the server administrator,
 and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.
More information about this error may be available
in the server error log.
Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2.2.23 (Unix) mod_ssl/2.2.23 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at Port 80
ReadyState: undefined

How can I solve this?

Comments

shad1981’s picture

I'm using a VPS hosting.

I think I found some errors at the WebHost Manager > Mod Security page:

GET = /file/ajax/field_medical_files/und/form-gJXMhZDV2xSwPK84pRLwjFVfaevPnHHosFLcRQlEEk4 HTTP/1.1
Message = Input filter: Failed to create temporary file: /root/tmp/20130227-161258-US522UUQwm4AACm0IQkAAAAE-request_body-xE3yUb
GET = /file/ajax/field_test_images/und/0/form-hp_2b71x4bDxC_MJ9HHtNnpVbeZrqZ0fk2rKAz4B6Us HTTP/1.1
Message = Rule 239fee0 [id "-"][file "/usr/local/apache/conf/modsec2.user.conf"][line "354"] - Execution error - PCRE limits exceeded (-8): (null).

Does this help?

shad1981’s picture

I tried what violentlyjoyous suggested on comment 25:
adding Redirect 302 /misc/jquery.cookie.js /misc/jquery-cookie.js to .htaccess
and renaming (or copy) your jquery.cookie.js to jquery-cookie.js.

It didn't work.

shad1981’s picture

In case someone with the same problem google this in future...

The problem was caused by ModSecurity: "ModSecurity is an open source, free web application firewall (WAF) Apache module. It provides an external security layer that increases security, detects and prevents attacks before they reach web applications. It provides protection from a range of attacks against web applications and allows for HTTP traffic monitoring and real-time analysis with little or no changes to existing infrastructure."

Apache's ModSecurity can have issues with different CMS's although these can be corrected through selective whitelisting of the affected URI's involved. This is by far the best method of ensuring that ModSecurity protects your site from malicious attacks and hacks while allowing your site to function as intended.

I contacted my hosting provider Liquid Web and they immediately parsed the logs, and whitelisted the rules being tripped for the URI's involved.

Now it works fine!!!

jsimonis’s picture

Just sent an email over to StormonDemand and linked to your comment so that they can do the same for me. So glad you posted this item!

shad1981’s picture

I hope it solved your problem..
At first, I tried unsuccessfully to google the problem. When I couldn't find an answer, I contacted my host - Liquid web. Their response was quick and professional. Like always.

jsimonis’s picture

It sure did solve it. They were going to be my next point of contact, but I always start with a quick search of Drupal first to see if anyone's had the same problem. They had the rule whitelisted within minutes and I was uploading my file. They're such a great host!

Anonymous’s picture

In case anyone stumbles across this post from a google search, I am experiencing the same problem in a Drupal 7.24 deployment.

Anonymous’s picture

I have a field collection that includes a file upload field. The field collection is set to "unlimited" in the content type. This may be causing a loop that results in the max size exceeded error.

Here is a link to the issue; https://drupal.org/node/2205241

jamesf408’s picture

Thanks for the suggestion.  I contacted acorn hosting and they whitelisted the rule in Apache's mod_security so that file uploads can continue to work.

All works fine again.

mazwakefield’s picture

Hi There,

I think im having the same issue however am by no means a developer with this type of skill level.
I wrote to my hosting provider (Zip Hosting) and they refused to help. Their support reply was:

Thank you for providing us these details however we are a web hosting provider and website development is not part of our support scope.
The modsecurity is configured to your website via scripting. If you need to make changes to your scripting, you can either do this on your own, contact a developer to do it or provide us the specific details you wanted to change in the server.
The information you have provided is too lenghty and we are not trained to review website programming solutions so you'll have to provide us the exact steps that you wish for us to change if this is a server-related issue, which we do not believe is the case.
Feel free to reply to this email with additional information or questions with regards to your issue.

I'm pretty annoyed as this reply took a week to get to me!
Can anyone help me tell them what to do??

THANKYOU!!

juankvillegas’s picture

I faced the same issue and thanks to your message I found that the issue was caused by ModSecurity. Thank you.

chandan chaudhary’s picture

You need to check "LimitRequestBody" value in you ini file. This is ideally to set the size of file to get uploaded on server.

Need Drupal help?
Reach me

Acquia Certified Developer

Backend Frontend and DevOps.

aaronbauman’s picture

I figured this was a server-conf issue rather than a Drupal issue.
Disabling suhosin php extension fixed the same problem for me.

Symptoms were not helpful - 500 responses, no entries in php logs, no watchdog logs.

mehrdad201’s picture

Thanks a lot aaronbauman

Your solution worked for me

madelyncruz’s picture

Thank you, aaronbauman. Your solutions works. Suhosih was the culprit on 500 responses when the ajax runs, but I just found out that the Suhosih extension needs to be enabled for security. Is there any solution aside from disabling the Suhosih?

dennis.hill.aus’s picture

Hello everyone,
I was having the same problem where a file could not be uploaded, with the same error being displayed.
I updated my PHP from 5.4 to 5.5 and it appears to have fixed my issue.

kartagis’s picture

I had the same issue, and it was solved by disabling Filefield nginx progress

onlinkall’s picture

just you can request your hosting provider to added into the sites whitelist.conf file :

<IfModule mod_security2.c>
<LocationMatch .*>
SecRuleRemoveById 340147
</LocationMatch>
</IfModule>
spacetaxi’s picture

In my case, the problem was due to the Multiviews setting that is enabled on the server. I disabled it by adding the following line at the top of the .htaccess file:

Options -MultiViews