jadeg Posted May 1, 2014 Share Posted May 1, 2014 I'm getting an error message anytime I try accessing a file on a remote FTP server. Here is the code I've got $ftp_server="server"; $ftp_user_name="user"; $ftp_user_pass="passs"; $conn_id = ftp_connect($ftp_server) or die ("Couldn't connect to $ftp_server"); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if($login_result){ ftp_pasv($conn_id, true); $handle=fopen('crio/criolive.csv); } I get this error message Warning: fopen(/cro1/cRIO01_live.csv) [function.fopen]: failed to open stream: No such file or directory in /home/a5045426/public_html/sample.php on line 39 any pointer to why this is? Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted May 1, 2014 Share Posted May 1, 2014 the path shown in the error message doesn't match what you are showing in your code. the posted fopen() line of code is also invalid, containing a syntax error and is also missing a 2nd parameter. if you want programming help, you must show accurate, unadulterated information. Quote Link to comment Share on other sites More sharing options...
jadeg Posted May 1, 2014 Author Share Posted May 1, 2014 Sorry about that. This is the code $ftp_server="server"; $ftp_user_name="user"; $ftp_user_pass="pass"; $conn_id = ftp_connect($ftp_server) or die ("Couldn't connect to $ftp_server"); $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); if($login_result) { echo '<h1> Last Second Reading for Bridgetford T1 </h1>'; if(($handle = fopen('/crio1/cRIO01_csv', "r")) !== false) { $data = fgetcsv($handle, 0, ","); var_dump($data); } } with this I get the above error Quote Link to comment Share on other sites More sharing options...
bsmither Posted May 2, 2014 Share Posted May 2, 2014 /cro1/cRIO01_live.csv (error entry) still does not match /crio1/cRIO01_csv (code) Might there be an issue with PASV? Quote Link to comment Share on other sites More sharing options...
jadeg Posted May 2, 2014 Author Share Posted May 2, 2014 I have tried making a passive connection and still it does not work Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted May 2, 2014 Share Posted May 2, 2014 FTP is a protocol that is created/designed for the transferring of files from a remote location to a local machine, or vice versa. As a file transfer protocol, FTP is only capable of transferring files from one point to another, and some basic file operations, like copying, moving, or deleting files and directories on the remote machine. In your example you're trying to run a command whose is not a part of the ftp protocol. That's why you failed. To be able to run a wide variety of applications or commands on the remote machine using your local one you need to use a different approach like a SSH or vulnerable Telnet network protocol. Quote Link to comment Share on other sites More sharing options...
jadeg Posted May 3, 2014 Author Share Posted May 3, 2014 Thank you. I have tried this previously on another sever and it seemed to have worked file Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted May 3, 2014 Share Posted May 3, 2014 the fopen() statement doesn't even have anything to do with ftp, assuming you are trying to open the .csv file on the server where this code is running. based on your last posted code, the error you are getting means what it says, either the file or directory you are using in the fopen() statement doesn't exist. you are aware that the leading / you have on the file system path refers to the root of the current hard disk? Quote Link to comment Share on other sites More sharing options...
jadeg Posted May 3, 2014 Author Share Posted May 3, 2014 now I have tried fopen('ftp://user:pass@server/crio1/cRIO01_live.csv', "r") Now I get the error fopen() [function.fopen]: Couldn't resolve host name in Quote Link to comment Share on other sites More sharing options...
jazzman1 Posted May 4, 2014 Share Posted May 4, 2014 (edited) What's the host's name? Does it contain any special chars? If the "crio1" directory is in relative path to public_html, try to set absolute path to this file, something like, fopen('ftp://user:pass@server/home/username/public_html/crio1/cRIO01_live.csv', "r") We need to know the absolute path to this directory on the file structure in the remote machine! http://ca2.php.net/manual/en/function.getcwd.php Edited May 4, 2014 by jazzman1 Quote Link to comment Share on other sites More sharing options...
jadeg Posted May 5, 2014 Author Share Posted May 5, 2014 Thanks for the responses, the password contained a special character and that was the issue Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.