I have a problem with my ftp_get() and it really makes me confused.
I work on a local development (right now) and my FTP server is on my own computer. I want to upload/download files using FTP. I have yet managed to upload files with ftp_put(), it's ok. Now for downloading, I can change to the right directory of my FTP server, I can list the files via ftp_nlist(), it's OK for that, but when I do ftp_get(), my Apache log says me for [client 127.0.0.1]:
PHP Warning: ftp_get(): failed to open stream: Permission denied in /var/www/public_html/myfile.txt on line 62
PHP Warning: ftp_get(): Error opening myfile.txt in /var/www/public_html/myfile.txt on line 62
Line 62 is where I do my ftp_get, like this:
ftp_get($conn_id, $local_file, $server_file, FTP_BINARY)
I've done a lot of searches and answers are always like "beware of the owner" or "beware of the chmod" but I can't figure out what really is the thing I need to do. The owner of the root directory of the FTP server is the same as the owner of the file I try to download. So I don't know what to do, I think there is something confused in my mind.
Related
I just changed hosting companies and I have created a new WP install and we created a new website (We did not move over the old site). I just realized there was a second WP install on the old hosting account for a scholarship contest and I need to move that over to the new hosting company. I moved over the database and all of the files. I also updated the wp-config file with the database and username/password. But when I try to verify the site here aflbs.org/scholarshipcontest I am getting the below errors. Am I missing a step somewhere?
Warning:
require(/home/aflbs/www/www/scholarshipcontest/wp-includes/load.php):
failed to open stream: No such file or directory in
/home/aflbs/www/www/scholarshipcontest/wp-settings.php on line 19
Warning:
require(/home/aflbs/www/www/scholarshipcontest/wp-includes/load.php):
failed to open stream: No such file or directory in
/home/aflbs/www/www/scholarshipcontest/wp-settings.php on line 19
Fatal error: require(): Failed opening required
'/home/aflbs/www/www/scholarshipcontest/wp-includes/load.php'
(include_path='.:/usr/local/php56/lib/php') in
/home/aflbs/www/www/scholarshipcontest/wp-settings.php on line 19
Please check whether web server have appropriate permission to access files or not. This usually happens due to permission or ownership.
Try changing permissions and see if it works.
I have seen different variations of this problem which I have tried to use without any success so i figured it would be best just to ask.
I recently moved my website from my wamp server over to my qnap server. Seams to be working quite well except 3 errors that popped up (did not have them on my local host and havent changed any of the code).
I get the following 3 errors.
Warning: include(/share/HDA_DATA/Web/application/views/errors/html/error_php.php): failed to open stream: No such file or directory in /share/HDA_DATA/Web/system/core/Exceptions.php on line 269
Warning: include(): Failed opening '/share/HDA_DATA/Web/application/views/errors/html/error_php.php' for inclusion (include_path='.:/etc/config/php') in /share/HDA_DATA/Web/system/core/Exceptions.php on line 269
Warning: include(/share/HDA_DATA/Web/application/views/errors/html/error_php.php): failed to open stream: No such file or directory in /share/HDA_DATA/Web/system/core/Exceptions.php on line 269
Warning: include(): Failed opening '/share/HDA_DATA/Web/application/views/errors/html/error_php.php' for inclusion (include_path='.:/etc/config/php') in /share/HDA_DATA/Web/system/core/Exceptions.php on line 269
I seam to understand what is going on that it cannot access the file but can anyone point out what i need to change and where/which file i need to change it. I have not done any changes to my codeigniter file structure (all original setup). If you need code dump just let me know from which file.
Thank you for your help.
Jonas
I am trying to visualize a file file.txt via php. It is present in the same folder as the php code. this file is outcome of a perl program 1.pl
I am using the following code:
exec("perl C:/inetpub/wwwroot/1.pl arg1");
include("ctrlG.txt");
I have fast-cgi module activated on my server, which works fine otherwise.
Both the above are not executing.
It returns following Error:
PHP Warning:
include() [<a href='function.include'>function.include</a>]: Unable to access ctrlG.txt in C:\inetpub\wwwroot\upload_file.php on line ##.
PHP Warning:
include(ctrlG.txt) [<a href='function.include'>function.include</a>]: failed to open stream: Permission denied in C:\inetpub\wwwroot\upload_file.php on line ##.
PHP Warning:
include() [<a href='function.include'>function.include</a>]: Failed opening 'ctrlG.txt' for inclusion (include_path='.;C:\php\pear') in C:\inetpub\wwwroot\upload_file.php on line ##.
Please help to correct the code or any other problem.
OR
better methods to execute perl and visualize text files in browser using php.
Firstly, check the file you're looking for exists:
$file = 'ctrlG.txt';
if(!file_exists($file)) die("File '{$file}' does not exist");
Secondly, check if it is readable:
if(!is_readable($file)) die("File '{$file}' is not readable");
The most likely scenario is that the file exists and does not have readable permissions set so that apache (or whatever user your web server is running as) can read it.
Bear in mind that if you first ran this script through CLI (command-line interface) then the file generated will probably be owned by the user who ran the script - so apache may not be able to read this file for security reasons.
In Linux, you can change the file group and permissions to be readable by the apache user like so:
chgrp apache ctrlG.txt
chmod g+r ctrlG.txt
I learning how to write a WordPress plugin. I need some help writing some data to an XML file. I'm on my local machine, a Mac running MAMP. I have PHP 5.2.13. In my plugin, I've got:
$file_handle = fopen('markers.xml', 'w');
$stringdata = "Test Info";
fwrite($file_handle, $stringdata);
fclose($file_handle);
Running the above gives me the following error:
Warning: fopen(markers.xml) [function.fopen]: failed to open stream:
Permission denied in
/Users/my_name/Sites/my_site/wp-content/plugins/my_plugin_folder/my_plugin_main_file.php
on line 73
Warning: fwrite(): supplied argument is not a valid stream resource in
/Users/my_name/Sites/my_site/wp-content/plugins/my_plugin_folder/my_plugin_main_file.php
on line 75
Warning: fclose(): supplied argument is not a valid stream resource in
/Users/my_name/Sites/my_site/wp-content/plugins/my_plugin_folder/my_plugin_main_file.php
on line 76
I tried using the absolute path in the $file_handle line: http://my_site/wp-content/plugins/my_plugin_folder/markers.xml. But, that didn't work.
I also tried changing the permissions on markers.xml as follows:
(Me): Read & Write
(unknown): Read only
everyone: Read & Write
For some reason, my Mac wouldn't let me change (unknown) to Read & Write. I'm not sure if that makes a difference. I right-clicked on the file and selected 'Get Info' in order to change the permissions.
In phpInfo(), I've got:
"Registered PHP Streams https, ftps, compress.zlib, compress.bzip2, php, file, data, http, ftp"
Is a WordPress setting causing the problem? or is it just PHP issue?
Any suggestions on how to solve this problem?
Thank you.
You may need to change the permissions as an administrator. Open up terminal on your Mac and then open the directory that markers.xml is located in. Then type:
sudo chmod 777 markers.xml
You may be prompted for a password. Also, it could be the directories that don't allow full access. I'm not familiar with WordPress, so you may have to change the permission of each directory moving upward to the mysite directory.
[function.fopen]: failed to open stream
If you have access to your php.ini file, try enabling Fopen. Find the respective line and set it to be "on": & if in wp e.g localhost/wordpress/function.fopen in the php.ini :
allow_url_fopen = off
should bee this
allow_url_fopen = On
And add this line below it:
allow_url_include = off
should bee this
allow_url_include = on
I wrote a FTP app that uploads files to a remote server with PHP FTP's functionality. However I constantly get the following error ftp_put() [<a href='function.ftp-put'>function.ftp-put</a>]: Ok to send data. and have no idea what this means.
This is how the line looks where I'm getting the error ftp_put($connection, $main_dir.'/class.phpmailer.php','class.phpmailer.php', FTP_ASCII)
I even CHMOD the class.phpmailer.php file to 777 -rwxrwxrwx 1 apache apache 74526 Feb 11 12:16 class.phpmailer.php and still nothing, I do not know why this is happening.
Try to switch to passive mode ftp_pasv() after you login, but before you upload. If it doesn't help, put more code here (connect, login, etc.)