Hello to all, I'm new here at drupal community:

I have a problem when I access drupal 7 index for the first time.

It gives me the next error:

Warning: file_put_contents(temporary://file1Yl6Vj): failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data() (line 1832 of /var/www/www.site.com/public/includes/file.inc).

Here the line 1832:

if (file_put_contents($temp_name, $data) === FALSE) {

Thanks for the help.

Comments

koteo’s picture

I have write permissions for nobody user on /tmp. When it gives me the error I look at /tmp and I see new files with the next permissions:

-rw------- 1 nobody nobody 0 nov 2 05:42 filegOposQ

koteo’s picture

The problem was, that drupal haves for default other $TMP directory than php.ini. I changed drupal configuration on admin/settings/file system and now It works.

Thanks for the help.

vlindertje’s picture

I install a new fresh drupal 7.0
After install i saw the site with the next warning:

Warning: file_put_contents(temporary://fil9EB4.tmp): failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data() (regel 1847 van D:\www\site.nl\www\includes\file.inc).

I look at this site for help and found this topic with the same problem, but now i don't know what i have to change to fix this.

I went also to admin-settings-file system and see the problem, but i don't know how to fix it. Please help me?
I go to my database to check if there is a d:/tmp, but there isn't one.
And in the same settings (admin-settings-file system) i see that "path of the private file system" is empty.

Everything has read and write permissions.

Who can help me to fix this problem?

ihitro’s picture

I had the same problem with drupal 7

What did i do...

1. Make a directory /tmp

2. Make /tmp chmod 0777

3. Change file.inc on 1839

function file_unmanaged_save_data($data, $destination = NULL, $replace = FILE_EXISTS_RENAME) {
  // Write the data to a temporary file.
  $temp_name = drupal_tempnam('tmp/', 'file');
  if (file_put_contents($temp_name, $data) === FALSE) {
    drupal_set_message(t('The file could not be created.'), 'error');
    return FALSE;
  }

  // Move the file to its final destination.
  return file_unmanaged_move($temp_name, $destination, $replace);
}
yukey208’s picture

我的问题也是根据你的思路去解决了,只不过我把 $temp_name = drupal_tempnam('tmp/', 'file'); 中的tmp换成了temp之后刷新三次页面 问题解决。 Thanks ihitro!

Anonymous’s picture

It works for me thanks

junix33’s picture

This works for me too.
Thanks guys!

fyl’s picture

If Drupal is going to pick the path for storing temporary files (/tmp) at install time, it seems that the installer should make sure this exists and is writeable and tell you there is a problem if it isn't.

My first D7 two D7 installs didn't have this problem but on my third, the shared hosting site doesn't give users access to /tmp. Each user has ~/tmp to use within their own file space. (Note that this is on Site5.)

Davinia’s picture

I think I'm just blonde, but I don't understand the solution.

What do I have to do to fix this problem??

phonographstudio’s picture

It seems that when you move a D7 site to a new host, the temp directory path is kept in the settings. Therefore, if this path change, this error can occur.

You can fix this at the following url : admin/config/media/file-system

Look for temp folder.

Hope this helps.

davidhunter’s picture

Perfect! Thanks for this answer.
I have a local install on my Windows PC, and moved to a devel server in Linux. Path was still set to C:\xammp\etc, etc

dave

fcastrouk’s picture

I solved my problem with your solution.
Thanks a lot

intaz’s picture

Hi im new to drupal, when i hosted the files i got below bug

* Warning: file_put_contents(temporary://fileuZCnZe) [function.file-put-contents]: failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data() (line 1847 of /home/coimbato/public_html/includes/file.inc).
* The file could not be created.
* Warning: file_put_contents(temporary://fileKVq6tM) [function.file-put-contents]: failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data() (line 1847 of /home/coimbato/public_html/includes/file.inc).
* The file could not be created.
could any one help me to clear the bug..
--Thanks

Jens Peter’s picture

I had the same problem.
On ftp server when you go to the folder /sites/default/files/tmp/ you will find a .htaccess file.
Delete this and the error is gone - or at least it was for me.

I dont see the point in adding a .htaccess file in this folder and I am not sure why this happens.

Hope it helps...
Jens Peter

AzMCHICHI’s picture

Hi,
You have only to create a directory named "temporary" in sites/default/files
It works for me

--
Abdel.MA

sircosta’s picture

First go to: admin/config/media/file-system

and check the personal directory. [It use to be ~/tmp]

then, in case you have "tmp", just create a new folder called "tmp".

It works fine to me! :)

As some of you comment, the problem maybe cames for the host changing.

alexmoreno’s picture

it gave me the same error. Enabling chmow a+rw or 777 permissions did not solve.

I finded the solution changing the owner / group:

chgrp -R www-data tmp
chown -R www-data tmp

www-data may differ from any server, simply using a ls -l in /var/www could give us the user and group needed.

datac99’s picture

This post came when I was doing a search for the same error, and my issue seems to have been similar to the original posters: The session.save_path in the php.ini was different then the setting in Administration > Configuration > Media > File system.

But I didn't want to change the setting in drupal as I am working with a copy of a site I have hosted elsewhere and wanted to maintain compatibility between the two installations.

The remote install is on a shared host, and the local install is on a windows box running WAMP_32. After a bit of digging I found I could edit the \WAMP_32\bin\apache\Apache2.2.21\conf\extra\httpd-vhosts.conf like so:

<VirtualHost *:80>
    <directory "g:/WWW Redirects/colonize">
        allow from all
        php_value session.save_path "g:/tmp"
    </directory>
    DocumentRoot "g:/WWW Redirects/colonize"
    ServerName colonizejupiter.local
    ServerAlias staging.anytimecomm.local
    ErrorLog "logs/colonizejupiter.local-error.log"
    CustomLog "logs/colonizejupiter.local.log" common
</VirtualHost>

The line of interest up there is: php_value session.save_path "g:/tmp"

Obviously you want the path to match your installation, and this won't work if you are not using vhosts, but the same php_value directive could probably be used elsewhere.

ha.azizi’s picture

hi
i read this topic, but i can't repair this problem.
i have 4 error:

Warning: file_put_contents(temporary://filevRxXRx) [function.file-put-contents]: failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data() (line 1903 of /home/pouyapol/public_html/includes/file.inc).
The file could not be created.
Warning: file_put_contents(temporary://fileIvFaLP) [function.file-put-contents]: failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data() (line 1903 of /home/pouyapol/public_html/includes/file.inc).
The file could not be created.

i can't install module and use views in site.

please help...

VM’s picture

where is your tmp folder and what are the folder permissions?

ha.azizi’s picture

all folders permission: 755
tmp: ??
Public file system path: sites/default/files

VM’s picture

well you need to know where your tmp folder is. if you don't know where it is you don't know that it's 755

Drupal checks a common path set in administer -> file system which is typically above the public root.

fstrevisan_eZly’s picture

Had the same problem with a new, fresh install of Drupal (using 7.23) on Windows 7 (IIS 7), MySQL 5.1 and PHP 5.3.

Already had a version of Drupal working, but it was copied from a Debian server and used \tmp (so, C:\tmp) while the fresh version used sites/default/files/tmp.

In my scenario, the problem was that a mysterious user IUSR (PHP maybe?) was the one trying to write to the folder, not the default IIS_IUSRS. Gave it the appropriate permissions and everything worked fine.

densolis’s picture

I am documenting this in case anyone else has this issue.

When I started up the site, I received the error message "Error viewing drupal index after installation (file_put_contents(temporary://file1Yl6Vj): failed to open stream)".

This is because the temporary file was set to "Applications/MAMP/tmp/php", which I did not have on my machine. I tried to create it, but I did not work. So I had to change the temporary file path. Unfortunately, you can not change it because you have to get into the site to change it and I could not login because the temporary files could not be created.

The paths are stored in the table named "variable".

So, the solution is:

1. Go to your command line box, navigate to the directory where the mysql command is stored ("C:\Users\Dennis\Sites\Drupal-UniServer\usr\local\mysql\bin" in my case), and enter:

mysql -u <user name> -p<password - no space> <database name>
SELECT * FROM variable WHERE name LIKE '%temporary_path';
UPDATE variable SET value='s:4:"/tmp";' WHERE name='file_temporary_path';
SELECT * FROM variable WHERE name LIKE '%temporary_path';
EXIT

**NOTE:** The "s:26" and "s:4" means the string is 26 and 4 characters long, respectively. Also, there is NO space after the -p (password parm). So yes, the -p should be -ppassword.

Here is a screen shot of what I did to fix this.

C:\Users\Dennis\Sites\Drupal-UniServer\usr\local\mysql\bin>mysql -u <username> -p<password> <databasename>
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 266
Server version: 5.5.20 MySQL Community Server (GPL)

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> SELECT * FROM variable WHERE name LIKE '%temporary_path';

+---------------------+------------------------------------+
| name                | value                              |
+---------------------+------------------------------------+
| file_temporary_path | s:26:"/Application/MAMP/tmp/php/"; |
+---------------------+------------------------------------+
1 row in set (0.01 sec)

mysql> UPDATE variable SET value='s:4:"/tmp";' WHERE name='file_temporary_path';

mysql> SELECT * FROM variable WHERE name LIKE '%temporary_path';
+---------------------+-------------+
| name                | value       |
+---------------------+-------------+
| file_temporary_path | s:4:"/tmp"; |
+---------------------+-------------+
1 row in set (0.01 sec)


Then I create the tmp directory and I was up and running.

PS. I could not use phpMyAdmin because it show the "value" field as a blob instead of a text string.

Dennis