move_uploaded_file gives: failed to open stream: Permission denied - php

I am working with two different servers, and uploading files between them. From one to another. But that is not working. It worked when both are on my localhost, but when I want to upload file from my localhost onto another server that is a cloud server. It is giving me this error:
Warning: move_uploaded_file(/var/www/data/user-blue.png): failed to open stream:
Permission denied in /var/www/upload.php on line 67
Warning: move_uploaded_file(): Unable to move '/tmp/phpVBiLvB' to '/var/www/data/user-blue.png' in /var/www/upload.php on line 67
How do I fix permissions on the cloud server? I have full root access if it is needed.

chmod on your directory to read write execute. Or give user permissions to te directory.

If you are using Mac OS, here are the simple steps you need to take to solve this problem of permission:
Double click on your upload folder to get options
Click on "Get info"
Scroll down, in the left bottom corner, you will see a padlock, unlock it with your pc password
Then you will see permissions in bottom, change the permissions to read and write
Problem solved. unless your script has a problem

Related

file_put_contents failed to open stream: Permission denied

Basic php and javascript website
No errors on Wamp
When I put the files on my Lamp server everything works except for this error I get on the top of the page
Warning: file_put_contents(donneesDonut.json): failed to open stream:
Permission denied in /var/www/html/bp/action/IndexAction.php on line
101
I looked around and most people suggest to change the permission of the file or the entire directory on apache.
chmod 777 did nothing for me.
I'm new to web servers so I probably have missed some apache configuration for permissions during the installation process
Here is a screenshot of the directory
Directory listing
I don't think there is a problem with the code since it works on my local Wamp server but here is the line of code that gives me the error.
file_put_contents($this->json, json_encode($this->donneesDonut));
If you need any other information like specific apache configuration please tell me where to get them.
Hope you can help
The problem was SELinux with was set to enforce by default on Centos

Include file from seperate domain on server: Failed to open stream: Permission denied

I just upgraded Plesk to the latest version and it has caused many of my sites to go down.
The websites all rely on a file which is located on another domain on my server so they all host an index file which contains an include like this:
include('/var/www/vhosts/assets-domain.co.uk/httpdocs/websites/index.php');
I am getting the following error when viewing the website:
Warning: include(/var/www/vhosts/assets-domain.co.uk/httpdocs/websites/index.php): failed to open stream: Permission denied in /var/www/vhosts/this-domain.co.uk/httpdocs/index.php on line 3 Warning: include(): Failed opening '/var/www/vhosts/assets-domain.co.uk/httpdocs/websites/index.php' for inclusion (include_path='.:') in /var/www/vhosts/this-domain.co.uk/httpdocs/index.php on line 3
So there is obviously a permissions problem of some sort but I have no idea where to start.
In SSH I have tried changing the ownership of the folder '/var/www/vhosts/assets-domain.co.uk/httpdocs/websites/' with no luck. I have noticed that all my domains have different ownership usernames now - would this affect it? EG.mydomain.com has the user of mydomain, cooldomain.com has the user of cooldomain - would this be why they can't access each others files?
Please help as I have 15+ websites down :-(
Fixed this - Plesk decided to change the permissions so simply changing the domain name folder to 755 solved this

PHP File Uploading Issues

I'm trying to implement script that will allow a file to be uploaded, and then moved to a designated directory. This is running on a Windows server & IIS. I'm having 2 issues in doing so.
First, I get an error when trying to move the file.
Warning: move_uploaded_file(reports/ff.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\inetpub\wwwroot\betterinsight\betterinsight\upload_file.php on line 29
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\Windows\Temp\php1EAB.tmp' to 'reports/ff.jpg' in C:\inetpub\wwwroot\betterinsight\betterinsight\upload_file.php on line 29
Stored in: reports/ff.jpg
When searching, almost everything says it's a permission problem. I have added full rights (will pare down later) to the user: IIS_IUSRS. Even did it to the parent directory as one site recommended.
Second: As a possible solution to the above issue, I tried changing the directory in which files are saved. But the files are still uploaded into C:\windows\temp.
I've run phpinfo, and it says that uploads should be in (as defined by upload_tmp_dir):
Again, this is on a Windows Server 2008. Thanks.
Permission denied
You need to set the folder permissions to 777 or enable read write to the folder. I think the permissions are messing...
OK, the answer was simple. I was adding permissions for user: IIS_USRS, when it should have been just user: USRS.

IIS website "failed to open stream: No such file or directory in C:\inetpub\vhosts\" but file exists there

Hi I have been struggle with a wierd problem. I am using IIS and moved one of my web site folder to desktop of my server and then put it back now I see
Warning: include_once(./lib/config.inc.php) [function.include-once]: failed to open stream: No such file or directory in C:\inetpub\vhosts\politikacim.net\httpdocs\index.php on line 12
Warning: include_once() [function.include]: Failed opening './lib/config.inc.php' for inclusion (include_path='.;./includes;./pear') in C:\inetpub\vhosts\politikacim.net\httpdocs\index.php on line 12
this kind of error. I looked at my root folder and see it's permission is system and administrator full access , how can I make it work ? Please help me.
Given the error messages, you'd need to have your config.inc.php file in one of the following locations:
C:\inetpub\vhosts\politikacim.net\httpdocs\lib\config.inc.php
C:\inetpub\vhosts\politikacim.net\httpdocs\includes\config.inc.php
C:\inetpub\vhosts\politikacim.net\httpdocs\pear\config.inc.php
system/admin permissions are irrelevant if your webserver is running under some other user account. You must grant permissions based on your webserver's userid, not your own personal one, or some other account.

Permissions error in WordPress site using move_uploaded_file on theme directory

I have a site in which I'm getting the following error when trying to use move_uploaded_file operation (see below)...
I also notice that when I attempt to delete a theme, WordPress asks me for my FTP credentials. I believe these issues are connected. Do you agree?
Warning:
move_uploaded_file(/home2/mySite/public_html/wp-content/themes/myTheme/myUpgrader.zip)
[function.move-uploaded-file]: failed
to open stream: Permission denied in
/home2/mySite/public_html/wp-content/themes/myTheme/upload.php
on line 79
Warning: move_uploaded_file()
[function.move-uploaded-file]: Unable
to move '/tmp/phpEva1Tw' to
'/home2/mySite/public_html/wp-content/themes/myTheme/myUpgrader.zip'
in
/home2/mySite/public_html/wp-content/themes/myTheme/upload.php
on line 79 There was a problem. Sorry!
I would say you lack permission necessary to write in the folder you are trying to upload those files or the owner of the folders is different by the owner running the PHP.
You can take a look here: http://onlamp.com/pub/a/php/2003/02/20/php_foundations.html
Or search for chown, chmod and maybe connect to your site with ftp and verify the CHMOD levels and who he owner is.

Categories