Jump to content

FTP server


jadeg

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/288145-ftp-server/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/288145-ftp-server/#findComment-1477878
Share on other sites

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.   

Link to comment
https://forums.phpfreaks.com/topic/288145-ftp-server/#findComment-1477914
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/288145-ftp-server/#findComment-1478048
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/288145-ftp-server/#findComment-1478193
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.