FTP in PHP not copy index.php file - php

I have a PHP script to copy all files in a directory i have change my server now its not copying index.php file all other files copy successfully and throw bellow warnings.
Warning: ftp_get(tmp/readme.txt): failed to open stream: Permission denied in /var/www/vhosts/Site.com/httpdocs/includes/ftp.class.php on line 123
Warning: ftp_get(): Error opening tmp/readme.txt in /var/www/vhosts/Site.com/httpdocs/includes/ftp.class.php on line 123
Warning: fopen(tmp/readme.txt): failed to open stream: Permission denied in /var/www/vhosts/Site.com/httpdocs/includes/clone.php on line 196

Seems like a permission issue on the new server. Double check the server directory you're accessing to make sure, you and apache have the appropriate permissions.

Like the error message says: Permission denied, in other words your script does not have permission to access the file tmp/readme.txt. Check that the user your PHP script is using has read access to the file/folder. The way to check that depends on what your server setup is so can't give more unless you provide more info about what your server is running.

Welcome to the unix world. It is a permission problem. If you have rights, you can fix it with the command chmod in the server.
$ ssh username#server
$ chmod PERMISSIONS /path/to/filr
check the man page of chmod to understand the permissions. probably you do something like this : +w

It seems this permission issue, not in the new server but in the old server.
Please check owner:group of the index.php file in old server, so that your script can access and manipulate the origin file.
One more thing. Did you run the ftp transfer script, in the browser or in the command line?
This is very important, because one can run the script with APACHE user (www-data) and the other method run the script with your system user.

Related

Error permission denied while chmod on linux server

I host a website on linux server, I have got an error chmod permission denied error. Basically i want to change file permission chmod(0755) after file upload for security purpose..Any one has any idea..
PHP upload permission problem
Assuming you are running PHP under apache. You will need to make sure apache has permission to perform this action. If you are calling php via the command line, make sure the user that calls the script has permission to perform this action

PHP copy file permissions denied with dynamic user system

I am trying to copy a file to user's directory. I run a small hosting service with every user having a seperate directory. I can't CHMOD the directories to allow the PHP (www-data) user as that will break FTP for the users and some other programs we have installed on our server.
However, PHP (the www-data) user, is allowed to run with sudo. is this a possible fix? If it is: how to run copy() with sudo.
If that is not possible, is there another solution for my problem?
Exact error:
PHP Warning: copy(/home/user_946221/383838/Modules/xxx.zip): failed
to open stream: Permission denied in
/panel/handlers/server_functions/download.php
Thanks,
Jesse
You should be able to do exec("sudo cp from to")
Best regards

Warning: file_put_contents(): failed to open stream: Permission denied

Hi I am new to Mac and web development..
These days I am trying to do a simple web page with a simple form with HTML and Javascript, and the form will be processed by PHP. The PHP will be access txt file, read from and write to this txt file.
The error message comes from this line of code.
file_put_contents("order.txt", $content);
and the error message is
Warning: file_put_contents(order.txt): failed to open stream: Permission denied in /Users/maoyang/Sites/3006/process.php on line 57
all the HTML and PHP codes are in the myname/Sites/3006 folder of my computer. I have done some research and all of them tells me that I need to change some configuration to make the txt file writeable, but really very confused how to do so. Anyone know a good instruction page I could follow(for mac environment).
Thank you very much..
On OSX Apache is run by the _www user. You need to make sure that this user has permissions to write on the file you want to modify. To do so, open a terminal window and type:
sudo chown -R _www:_www /Users/maoyang/Sites/3006
Fill in your Administrator user password when requested. This will change the ownership of the /Users/maoyang/Sites/3006 folder to the _www user (the same one that run Apache) so the webserver will have writing permission on that folder (and all subfolders and files)

PHP permissions denied failed to open stream

I have this code
<?php
$handle = fopen('names.rtf','w');
fwrite($handle, 'Alex');
?>
Warning: fopen(names.rtf): failed to open stream: Permission denied in
/Applications/XAMPP/xamppfiles/htdocs/file.php on line 3
And when I run it in comes up with that error. I've set my permissions on the folder to read & write for everyone. I'm not sure why else it would deny it.
Im using the latest Mac OS
There is possible, the issue is that your webserver or PHP instance is not running under the same user, you can check this using the get_current_user() function.
You can either configure apache to run with your privileges or give the folder more permissions, like 0777.but 0644 is enough for reading file. try to give permission according to it's usage.
Another thing, are you sure $outFile maps to an absolute path? Try doing:
var_dump(is_file("names.rtf"));

permission for my php to create a dynamic file on the server

For a project I need my php file to create a dynamic file (on remote server which I bought) which loads into a flash component. Everything is working fine on my localhost. But once I upload it to the server, it throws the following errors:
Warning: fopen(output.html) [function.fopen]: failed to open stream: Permission denied in C:\Inetpub\vhosts\x.co.in\httpdocs\blabla.php on line 25
Warning: DOMDocument::save(k_id.xml) [domdocument.save]: failed to open stream: Permission denied in C:\Inetpub\vhosts\x.co.in\httpdocs\blabla.php on line 136
where on those lines fopen is written.
I understood as there is no permission to my php file to create any dynamic files on the server. So i just wanna understand is there a way by which I can privilege my php to create that file on the server.
I've the login access, which I think I've to put somewhere in code before it tries to create such file...but i dont know how to figure this...any suggestions?
The user that runs the PHP process needs to have permissions to write new files in the target folder. On linux servers this is done using CHMOD.
chmod 777 -R /path/to/folder
777 is the permission (full permission for testing only), -R means recursive for the files/folders inside. As you are using windows just right click on the folder and look at properties and search for permissions.
Create a new directory where the PHP will write the files. For that directory set permissions to 705 (that is owner has Read, Write, Execute permission)
You can either do that using a FTP client (Filezilla) or via a Bash shell
mkdir inputfiles
chmod 705 inputfiles

Categories