If I enable Block cache I start getting these messages on top of my page: "The file could not be created."

Also, if I enable Optimize CSS all the style definitions disappear and I start getting only plain html.

I set files directory to be accessible and writable and executable by everybody but this had no effect..

Could someone give me a helping hand??

Thanks in advance!!

Comments

wpanssi’s picture

Correction to the post:
If I enable OPTIMIZE JAVASCRIPT I start getting these messages on top of my page: "The file could not be created."

nirbhasa’s picture

You didnt specify what files are not created - perhaps its the compressed css and js files.

Check to see if your tmp directory is properly specified - if not there will be a big red box around it

dddave’s picture

Check if the temp directory exists, is properly specified and is writeable (755).

imyour’s picture

its your path issue, it mostly happen when you transfer your remote drupal site to your local machine and set that up, the most important part is to setup the '/tmp' path, for you must have to go to:

admin-> config -> file system ( Under Media )

Then scroll down and change or correct the path of the tmp there eg:

Temporary directory: c:/wamp/tmp // in case if you are using WAMP server

In case if you are using any other AMP client eg ( XAMPP, MAMP or whatever ) use the exact path of the tmp here and this should do the job.

I hope this will help.
Good Luck!

solstice74’s picture

This fixed the problem for me. I am using MAMP so I changed the path to /Applications/MAMP

wpanssi’s picture

Thanks for your answers!

"The file could not be created" is the only info I get from Drupal. It is propably a js file because I start getting the message after enabling Optimize javascript.

I have given 755 permission to tmp directory. I even tried to give 777 permission but I still keep getting these messages.
I was wondering where it is said that tmp is the temp directory? Can I check this some where? Can I change what is the name of the temp directory?

I also see the following log entries reoccuring:
page not found: js/js_4ffd6ef7f07cbdf372cbb72c824c8b0b.js

file_get_contents() [function.file-get-contents]: Unable to access languages/fi_255152c941addc7539e8a2f17511de1d.js in /var/www/vhosts/sitename.com/httpdocs/uusi/2punatikka/includes/common.inc on line 2385.

file_get_contents(languages/fi_255152c941addc7539e8a2f17511de1d.js) [function.file-get-contents]: failed to open stream: Success in /var/www/vhosts/sitename.com/httpdocs/uusi/2punatikka/includes/common.inc on line 2385.

fopen() [function.fopen]: Filename cannot be empty in /var/www/vhosts/punatikka.com/httpdocs/uusi/2punatikka/includes/file.inc on line 757.

Any ideas based on these?? Might these relate to problems with css & javascript optimizing?

MaffooClock’s picture

I am also having this problem. I'll never call myself an expert, but I have been working with Apache for years and I'm no stranger to permissions in Linux. The /tmp directory is 777, and the sites/*/files directory is writable by the group. This is one site out of a multisite setup. All the other sites are fine, but one in particular exhibits this problem. I've written a custom theme, but my CSS is solid (no wierd comment blocks or @imports anywhere).

Upon further inspection, there are plenty of /tmp/file??????, but they are all empty. Also, inside sites/*/files/[css|js], there are plenty of CSS and JS files, but all are empty (size is 0). I just can't figure out why this is happening. I have deleted and re-created the sites/*/files and /tmp, but nothing changes. In fact, I've made absolutely no progress on this (other than disabling CSS and JS aggregation). I've even tried disabling the locale module.

What's strange is that, while performing troubleshooting out of pure desperation, I set the download method to private, and the site's theme displayed perfectly. I set it back to public (which is where it needs to be), and the theme went away again (of course, because the aggregated CSS and JS filed are empty).

Yet, the error persists: "The selected file /tmp/filemhapSY could not be uploaded, because the destination is not properly configured." (But the file exists! Its just empty!)

I've run across a few places where this same problem was described by another person, but they were either directly related to a module or they dead-ended (like this one has, a month ago) -- no one seems to know what's going on or they aren't sharing the solution. Thus, my two cents...

Edit:
I traced my problem to the copy() function not doing anything (line 258 of includes/file.inc). After a few hours of trying to figure out why copy() was creating empty destination files, I discovered that the filesystem was full. D'oh! Once I cleaned up some old backus and freed some space, my problem went away.

Nigel Cunningham’s picture

This error can be caused if the /tmp directory doesn't exist. If you're running chrooted (eg via php-fpm), make sure /tmp exists and is writable by the php process.

brandy.brown’s picture

I agree. You probably just need to add a tmp folder to your drupal root.

therobyouknow’s picture

Also check check correct path for /tmp in admin/config/media/file-system (Drupal7)

On my live production hosting for my site, this is /tmp - which appears to be the default

BUT

On my local development setup (using a WAMP stack (ZWAMP), this is tmp - without the preceding /tmp

I removed the preceding / on my local setup and this error 'file could not be created' disappeared.

The explanation would be that /tmp represents some other place on my machine - perhaps C:\tmp rather than a subpath on my docroot.

Obviously this is something to remember when uploading the development back to the internet as this setting needs to be changed back.

Ideally it would be better for me to figure out how to ensure /tmp works.

marty.true’s picture

This solved it for me. The settings were using a "local" path so it worked fine on local, until I uploaded to server. Thanks for the tip!

huythuan’s picture

My case I only need to change permission for files folder to 755

halth’s picture

That was the case for me! Thanks @huythuan!

--
Heitor Althmann
Drupal Developer

chri5tia’s picture

Not to sound simplistic, but I was having the same issue spontaneously, among others today, with our Drupal 7 website. What I found was that our server was at capacity on memory. Once I ended some mysql processes and restarted the server, the problem went away.

Run some tests to see what is eating your server CPU. In my case, it was a newly added nightly mysql backup for three different databases at the same time. My cache space was literally used up.

RealityBitesYou’s picture

means set $config['system.file']['path']['temporary'] = '[your temp directory in quotes]';

in settings.local.php

Partha Sarathi’s picture

I fixed it by added a tmp folder as per the location of settings.local.php

in my case it was:

$settings['file_temporary_path'] = 'sites/default/files/tmp';
$config['system.file']['path']['temporary'] = 'sites/default/files/tmp';

Thanks guys you all are awesome.