ftp file transfer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • omerbutt
    Contributor
    • Nov 2006
    • 638

    ftp file transfer

    hi i am stucked some where inthis work never did it before
    i some how not getting some path right , i am getting the warning
    Warning: ftp_fput() expects parameter 3 to be resource, string given in C:\xampp\htdocs \ews\projects\i mage-magick\imageMag ick\ftp-chk.php on line 91
    Code:
    class Ftp{		
    		function ftpTransfer($ftpstream,$ftp_user,$ftp_pass,$ftp_new_file,$ftp_path){
    			//Login to the FTP server
    			$login = @ftp_login($ftpstream, $ftp_user, $ftp_pass);
    			if($login) {
    				//We are now connected to FTP server.
    				echo "switching to $ftp_path<br />";
    				if(!ftp_chdir($ftpstream,$ftp_path)){
    					echo "Could not switch to the remote directory<br />";
    				}
    				if(!chdir("C:/xampp/htdocs/ews/projects/image-magick/imageMagick/")){
    					echo "Could not switch to the local directory<br />";
    				}
    				//Create a temporary file
    				if($this->getFiles($ftp_new_file,$ftpstream)){
    					return true;
    				}else{
    					return false;
    				}
    			}else{
    				echo "Could not Login to the remote site";
    			}
    		}
    		function getFiles($ftp_new_file,$ftpstream){
    			$source_file =	"INFO.txt";
    
    			//Upload the file to server
    			if(ftp_fput($ftpstream, $ftp_new_file, $source_file, FTP_ASCII)){
    				return true;
    			}else{
    				return false;
    			}
    		}
    	}
    	$myFtp=new Ftp();
    	/*	START	*/
    	$server_name="omaraslam.com";
    	$ftp_user='';
    	$ftp_pass='';
    	$ftp_path="/public_html/examples/";
    	$ftp_new_file=$ftp_path."omer.txt";
    	
    	//Open stream
    	$ftpstream = @ftp_connect($server_name);
    	
    	//Transfer Files Via Ftp
    	$A=$myFtp->ftpTransfer($ftpstream,$ftp_user,$ftp_pass,$ftp_new_file,$ftp_path);
    	
    	if($A){
    		echo "Success transferred!<br />";
    	}else{
    		echo "Failure!<br />";
    	}
    	//Close FTP connection
    	ftp_close($ftpstream);
    	echo "Operation Completed";
    regards,
    Omer Aslam
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    It looks like you are using the function parameters for ftp_put() but using the function ftp_fput()
    Code:
    ftp_fput(resource $ftp_stream, string $remote_file, resource $handle)
    ftp_put (resource $ftp_stream, string $remote_file, string $local_file)

    Comment

    • omerbutt
      Contributor
      • Nov 2006
      • 638

      #3
      yeah
      it was it i found it yesterday
      anyways thanks alot for your concern
      regards,
      Omer Aslam

      Comment

      Working...