File system is not writable - php

I installed Drupal 7 in a web host successfully.
After installing a module, I got an error errors and and status report gave me this error message:
File system Not writable
The directory /Applications/MAMP/tmp/php does not exist.
You may need to set the correct directory at the file system settings page or
change the current directory's permissions so that it is writable.
I check the permissions for (sites/default/files) and it has 755 permissions and I change it to 777 but nothing happened so I return it back.
I have the following setting for (Home » Administration » Configuration » Media):
Public file system path
sites/default/files
Temporary directory
/Applications/MAMP/tmp/php
and here is the error I am getting:
Warning: file_put_contents(temporary://fileDyFbDg) [function.file-put-contents]: failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data() (line 1898 of /home/imamus/public_html/includes/file.inc).
The file could not be created.
Warning: file_put_contents(temporary://fileeTFMpl) [function.file-put-contents]: failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data() (line 1898 of /home/imamus/public_html/includes/file.inc).
The file could not be created.
Warning: file_put_contents(temporary://fileuB8Tdu) [function.file-put-contents]: failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data() (line 1898 of /home/imamus/public_html/includes/file.inc).
The file could not be created.
Warning: file_put_contents(temporary://filea1KYXG) [function.file-put-contents]: failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed in file_unmanaged_save_data() (line 1898 of /home/imamus/public_html/includes/file.inc).
The file could not be created.
Please advice.

I check the permissions for (sites/default/files) and it has 755 permissions and I change it to 777 but nothing happened so I return it back.
do the same for /Applications/MAMP/tmp/php

This reply is for non-windows sites :
In my case, the sites/default/files/ folder was set to 775 ( not a good idea to have it set to 777 )
I had to delete the following folder :
rm -rf /tmp/devel_themer/
Then it worked !

The error happens, because your temporary directory is not writable by your web server user.
You may check that in admin panel by going to Reports and Status report at: /admin/reports/status.
To fix it, you've to got to File system in Configuration (at /admin/config/media/file-system), then change your temporary directory to point to your writable directory. If that's correct, then make you set the right permission on it, e.g.
sudo chmod -R 777 /Applications/MAMP/tmp/php
and the same for default files folder:
sudo chmod -R 777 sites/default/files
Drush
If you're using drush, check which folder is set currently by:
drush vget file_temporary_path
Then to fix it, try:
drush vset file_temporary_path /tmp
Here are default temporary directories:
OS X: /private/tmp, for MAMP: /Applications/MAMP/tmp/php
Linux/Unix: /tmp

Related

PHP 8 - Warning: Unknown: Failed to open stream

Consider:
I have a file called test.php. Here is the contents:
<?php
echo "Hello World";
?>
I have ensured my doc root has permissions as per Correct owner/group/permissions for Apache 2 site files/folders under Mac OS X?
When I try to run the above script on my MAMP stack I get this warning:
Warning: Unknown: Failed to open stream: Operation not permitted in Unknown on line 0
Could someone shed some light on my error here please?
Edit: I have tried the ideas below - thank you to #Shozabjaveed - but these have not worked.
Make Sure that the Apache service has read permissions.
chmod 755 test.php
or ran the recursive command to ensure that the Apache service has read permissions.if using MAC
sudo chmod -R 755 ~/foldername

move_uploaded_file failed to open stream: Permission denied Mac

I want to upload an image. Every time I try to upload the image I recieve the error message found below.
I have already set the permissions to read&write:
Warning: move_uploaded_file(uploads/1000020170620022532img3.png):
failed to open stream: Permission denied in
/Applications/XAMPP/xamppfiles/htdocs/social-network-master/profile.php
on line 41
Warning: move_uploaded_file(): Unable to move
'/Applications/XAMPP/xamppfiles/temp/phpYqSkvp' to
'uploads/1000020170620022532img3.png' in
/Applications/XAMPP/xamppfiles/htdocs/social-network-master/profile.php
on line 41
Friend, You only need only to create the directory where are your .php file is found:
uploads/
And change the Only write in the folder
Please use below code:
move_uploaded_file($_FILES['image']['tmp_name'],'uploads/1000020170620022532img3.png');
If this code is not working please check path and folder permission.
try this in terminal
sudo chmod -R 777 upload/
p.s. got to the upload directory and run sudo chmode -R 777 directly.

Opencart File Permission Error on frontend

I am working on a project hosted at 27littlethings.com and I can't seem to get rid of this error:
Warning:
fopen(/home/a27lifdy/public_html/system/storage/logs/error.php):
failed to open stream: Permission denied in
/home/a27lifdy/public_html/system/library/log.php on line 6
I have tried to change the file permissions on the specified file but the problem is not going away.
Change the permissions on the file in question:
chmod 755 /home/a27lifdy/public_html/system/storage/logs/error.php
or
chmod 777 /home/a27lifdy/public_html/system/storage/logs/error.php
You can also try just changing the permission on the folder:
chmod 777 /home/a27lifdy/public_html/system/storage/logs/

Permission denied for new php files uploaded by ftp user

When i try to upload php file using vsftpd to /var/www/ and visit the file from web server i got this error,
Warning: Unknown: failed to open stream: Permission denied in Unknown
on line 0
Fatal error: Unknown: Failed opening required
'/var/www/.../.../public_html/d.php'
(include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
i tried chown -R www-data:www-data /var/www after that the error got fixed but i have to do the same every time i upload a new file, is there is anyway to fix that for all new files?
The best way is to apply an ACL to the directory in question.
This will set the default so new files and folders are given the ACL, this says that the group of www-data will have read,write,execute permissions by default on all files/folders from /var/www recursively
sudo setfacl -Rdm g:www-data:rwx /var/www
This will set the ACL for existing files and folders, this says that the group of www-data will have read,write,execute from /var/www recursively for existing files and folders
sudo setfacl -Rm g:www-data:rwx /var/www

PHP Codeigniter error failed to open stream: Permission denied

I have been working on a project that uses codeigninter. I worked on it in Windows 7 and it was fine but after I moved this project on Ubuntu to work on it there, It gives me this error in every page/controller/method that I try to access:
Warning: require_once(/opt/lampp/htdocs/TS_Project/system/core/CodeIgniter.php): failed to open stream: Permission denied in /opt/lampp/htdocs/TS_Project/index.php on line 202
Fatal error: require_once(): Failed opening required '/opt/lampp/htdocs/TS_Project/system/core/CodeIgniter.php' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/TS_Project/index.php on line 202
The CodeIgniter.php file does exist, the path to it is correct and I am able to read and write in it ( I can open it in a text editor and modify it freely). I tried changing the file permission to it using the chmod command but nothing happens. Why is permission denied to the CodeIgniter.php file?
You need to change the permission of your TS_Project folder to 755.
You can do that by:
sudo chmod -R 755 /opt/lampp/htdocs/TS_Project

Categories