I have searched this forum and used my Google-Fu but I cannot find find for this error: "The file [file.jpg] could not be saved. An unknown error has occurred." Our developer (I'm the designer) is yet to be replaced, and we have a launch scheduled for Tuesday 9/3, so we're in a tough spot. The crucial element is to be able to upload images. All help is GREATLY appreciated.

We have several Drupal installs on this server, all referring to a shared module folder. We're getting this error across all of them.

When I hit Upload I get the error "The file [file.jpg] could not be saved. An unknown error has occurred." followed quickly by "Upload failed." The log is not catching anything, no errors. It's not a file size or type issue (been there), or user permissions (done that), or the particular directory being uploaded to (see: t-shirt). IMCE is up to date, and for giggles I made sure CKEditor was, too. I've confirmed that IMCE's settings are correct.

I'm thinking server permissions or Javascript issues...? Those both came up in my semi-relevant search results, but no one had success with permissions and I'm not sure how/what I need to do for the latter.

Same errors when use an image field on a node:

The file news.jpg could not be saved. An unknown error has occurred.
The file in the Blog Image field was unable to be uploaded.

CommentFileSizeAuthor
errpr.png2.85 KBRU.gould
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ufku’s picture

Priority: Major » Normal

This error thrown by includes/file.inc. PHP fails to upload a file but does not report any of the known error codes. You should check your web server logs.

beardedgeek’s picture

I have the same issue. Web server logs are empty.

beardedgeek’s picture

Issue summary: View changes

Additional info

bryanzera’s picture

I encountered this problem when I was out of space on the file system temporary directory

Check to see where your temporary directory is at admin/config/media/file-system and see if that disk is out of space.

bryanzera’s picture

UPDATE: While Drupal uses the temporary directory specified at admin/config/media/file-system, the server still uses whatever directory PHP specifies in the upload_tmp_dir variable in PHP.ini. The advice in the previous comment applies to this directory, too: Make sure that it's not full and that the file that you're uploading doesn't exceed the space available.

Sansui’s picture

I am also experiencing this issue. On a WHM/CloudLinux server I have several Drupal 7 sites running. It was running PHP 5.2.17 and I upgraded that to 5.4.23 using easyapache. After that update I get the generic error referenced in this thread that leaves no error logs on the server and has very few hits on google.

CloudLinux has the option of changing PHP versions for an account so I also tried 5.2 and 5.3

My tmp directory is fine and writeable, and in fact everything was working fine across these Drupal sites before the easyapache update. Image styles are being generated, modules are saving their thumbnails - it seems Drupal has no issue doing its own things with the existing files but users are unable to upload any files, anywhere.

No errors, no problems reported. Totally baffling.

keven1894’s picture

Issue summary: View changes

I have experienced the same issue several times. The solution might be different based on your hosting environment. I am hosting my Drupal site under a window 2008 server + IIS stack. However, I finally figured that the error about "could not be saved. An unknown error has occurred" especially when the log did not catch anything normally caused by permission issues.

The tricks to fix this problem is about set correct user for corresponding directories:

  1. First of all, refer to [your site]>>Administrator>>Configuration>>Media>>File system for your Public file system path and Temporary directory.
  2. Make sure grant write permission on your server to the web server user (IUSR for IIS).
  3. Another very tricky part is for the PHP.ini config which looks like only occurred on Window server. There is a setting for upload temp folder:
  4. ;Temporary directory for HTTP uploaded files (will use system default if not
    ;specified).
    ; http://php.net/upload-tmp-dir
    ; upload_tmp_dir =
    If you already try everything and nothing works, just uncommon this line and specify a temp folder path (e.g. c:\files\temp) and grand iis user write permission. This will automatically rewrite your Drupal site temp file folder to this location. It will fix the issue

Ked’s picture

Can confirm keven1894's solution worked for me.

This issue occurred after migratin a Drupal install to a new server with a new PHP config.

Edited php.ini and set upload_tmp_dir = /tmp (on Linux). Works perfectly now.

rutgers03’s picture

For linux I added the /var/tmp folder and that worked as well.

lolmanKD’s picture

Normally this issue occurs in old versions of Drupal 7.

The file upload issue are generally related to permission issues or the .htaccess issues.

  1. Check if the /tmp folder is properly configured in Drupal or not. (path of tmp file)
  2. Check for the permissions of the tmp folder and the files folder if they are (755) or above.
  3. Check if there is any .htaccess file present in tmp folder & if it consists this line Deny from all
  4. If point 3 is valid then replace the line with the following lines of code
    SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006
    Options None
    Options +FollowSymLinks

This will definitely solve your problem.

Thanks!

AswathyAjish’s picture

#9 worked for me. Thanks a lot.

thalles’s picture

Thanks @all!

thalles’s picture

thalles’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

prairiedog’s picture

In our case, the client had exceeded their disk quota on the server. We cleared up some room, and things were back to normal instantly. Just FYI in case it helps anyone dealing with this error.

voam’s picture

On a windows 10 developer machine in php.ini I set

upload_tmp_dir ="C:\logs\tmp"

and gave the IUSR account write permission of that directory.

Within the drupal site app I also created the directory sites\default\files\tmp, but I am not sure if that made a difference.

In any event, now the styles are appearing as expected.