move_uploaded_file failed to open stream: Permission denied Mac - php

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.

Related

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/

imagejpeg - Unable to open file for writing: Permission denied

I am getting this error / warning:
Warning: imagejpeg(): Unable to open
'/var/www/my_web/data/my_web/www/users/avatars/user125.jpg' for
writing: Permission denied in
/var/www/my_web/data/classes/class.Image.php on line 157
On line 157, there is
imageJPEG($image, $this->destPath, $this->jpgQuality);
My avatars folder has permission set to 777, $this->destPath is '/var/www/my_web/data/my_web/www/users/avatars/user125.jpg'
How could I solve this problem?
Set destination path to 777 permission with user www-data
be careful with the user-group : www-data
chmod -R 777 /var/www/my_web/data/my_web/www/users/avatars/
"The "-R" stands for "recursive" which means that the command will affect every single file within the directory you choose." (from comments #lefdilia)
You should set 777 permission for jpeg file too.
Check permission of jpg.

require_once() Permisson Denied even after chmod 777

I do Dropbox-API
it needs to access the Dropbox-SDK..
Here is the error shown in browser.
Warning: require_once(dropbox-sdk/Dropbox/autoload.php): failed to open stream: Permission denied in /home/albert/public_html/test/search.php on line 11
Fatal error: require_once(): Failed opening required 'dropbox-sdk/Dropbox/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /home/albert/public_html/test/search.php on line 11
I have been researching about it and try to chmod all the files, also chown all.. but it still show the same error..
Can anyone help? Thx
Check your include path for it may be that you have to change it or include/require the autoload file using its full path.
Is dropbox-sdk/Dropbox/autoload.php under . or /usr/share/php or /usr/share/pear, if not, that is your problem - your include path is incorrect, or your installation path for Dropbox was placed in the wrong place

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

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

Categories