PHP 8 - Warning: Unknown: Failed to open stream - php

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

Related

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.

XAMPP Permission Denied for Require_Once Mac OS X Yosemite

Problem:
I'm trying to open headerr.php via require_once on a XAMPP localhost server. I'm calling this function through index.php but I keep on receiving the following error message
Errors:
Warning: require_once(/Applications/XAMPP/xamppfiles/htdocs/Baseline/headerr.php): failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/Baseline/index.php on line 2
Fatal error: require_once(): Failed opening required 'headerr.php' (include_path='.:/Applications/XAMPP/xamppfiles/lib/php') in /Applications/XAMPP/xamppfiles/htdocs/Baseline/index.php on line 2
Attempted Solutions:
-I've tried setting the permissions to Read & Write for everyone on the (/Applications/XAMPP) Folder but that hasn't fixed the permissions issue.
-I've also tried using require_once dirname(FILE) . '/headerr.php'; but that didn't work either..
In Conclusion:
I suspect that I may have to edit the php.ini file but I have no clue what to do..
I appreciate any advice or insight, thanks!
Try this command:
chmod -R 775 yourWebFolder

warnings trying to start cakephp

When I try to start cakephp it shows me some warnings messages:
Warning: SplFileInfo::openFile(.../cake_2_0/app/tmp/cache/persistent/myapp_cake_core_file_map): failed to open stream: Permission denied in .../cake_2_0/lib/Cake/Cache/Engine/FileEngine.php on line 357
Warning (512): SplFileInfo::openFile(cake_2_0/app/tmp/cache/persistent/myapp_cake_core_cake_dev_en-us) [splfileinfo.openfile]: failed to open stream: Permission denied [CORE/Cake/Cache/Engine/FileEngine.php, line 357]
Warning (512): _cake_core_ cache was unable to write 'cake_dev_en-us' to File cache [CORE/Cake/Cache/Cache.php, line 325]
I'm using xampp on linux and as far as I know writing and reading permissions are enabled within the folders.
Does anybody know how to solve this?
There was a bug report there http://cakephp.lighthouseapp.com/projects/42648/tickets/2172 but it was considered as not being a bug.
Also try this
chgrp -R www-data app/tmp
chmod -R g+rw app/tmp
find app/tmp -type d -exec chmod g+s {} \;
Hope it would help you
You should check the version of php ^ ^
Cake requires php 5.2.8 or newer

File system is not writable

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

Linux/php require parent directory

I am on Ubuntu 11.10 and installed apache server to host my local website before i host it from a company.
My website root location is "/home/a1a4a/www/"
I have a php file in /home/a1a4a/www/account/account_info.php"
That i want him to include a file in "/home/a1a4a/www/include/fg_membersite.php"
It's what i did from account_info.php
require_once('./include/fg_membersite.php');
And i got this error
Warning: require_once(./include/fg_membersite.php): failed to open stream: No such file or directory in /home/a1a4a/www/account/account_info.php on line 10 Fatal error: require_once(): Failed opening required './include/fg_membersite.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/a1a4a/www/account/account_info.php on line 10
So what have i done wrong ? How to fix .
I have full permissions ( sudo chown -R www-data ).
Thanks and Happy Holidays :)
Always use the absolute path or you will face errors depending on the calling script.
require_once('./include/fg_membersite.php');
should actually be
require_once(dirname(dirname(__FILE__)).'/include/fg_membersite.php');

Categories