it is not about for something i ask you to give me any code.
how i can work on ssh.
it new for me.
i already work on it from last week, i gather alot of data about it but still i am confused.
my server is ssh.
through ftp i am accessing the the server and i can read file over there, but when i am trying to upload file then i have the following error,
if you like then i am sending my code as well check it if you want, i am not forcing you,
<?php
function rec_copy ($source_path, $destination_path, $con){
//print "hello\n";
if (@ftp_mkdir($con, $destination_path)) {
echo "successfully created $destination_path\n";
} else {
echo "$destination_path may already exist\n";
}
ftp_site($con, 'CHMOD 0777 '.$destination_path); //set writeable
$buff = ftp_rawlist($con, ".");
echo "<br/>";
var_dump($buff);
ftp_chdir($con,$destination_path); //move to remote directory
if (is_dir($source_path)) { //check for local directory
chdir($source_path); //change to local directory
$handle=opendir('.'); //open current directory
while (($file = readdir($handle))!==false) { //read files
echo $file . "\n";
if (($file != ".") && ($file != "..")) { //if not an unwated file
if (is_dir($file)) { //if is a directory
if($file != "propertyimages") { //here i am restricting the folder name 'propertyimages' from being copied to remote server. -- VK
rec_copy ($source_path."/".$file, $file, $con); //call this function on new directory
chdir($source_path); //change to server local directory because after calling this function the ftp handle would be inside said directory
ftp_cdup($con); //change to parent directory on server
}
}
if (is_file($file)) { //if is a file
$fp = fopen($file,"r"); //open local file for reading
if (ftp_fput ($con, $file, $fp,FTP_BINARY)) {
// echo "successfully uploaded $file\n";
fclose($fp);
$command ="echo Y| cacls \"" . realpath($source_path) . "\\" . $file."\" /G administrators:F";
//echo $command . "\n";
$e = exec($command) . "\n";
unlink($file);
} else {
echo "There was a problem while uploading $file\n";
}
ftp_site($con, 'CHMOD 0755 '.$file); //set permissions
}
}
}
closedir($handle);
}
}
print "Starting FTP!\n";
$con = ftp_connect("bbbbbbbbbbbbbbbbbbbbbbbb);
//$con = ftp_ssl_connect("bbbbbbbbbbbbbbbbbbbbbbb);
// make a FTP connection --VK
$login_result = ftp_login($con,"nnnnnnnnnnnnnnnnnnnnnnnnnnnnn"); // login
//$con =ftp_connect("bbbbbbbbbbbbbbbbbbbbbbbbb);
//$login_result=ftp_login($con,"bbbbbbbbbbbbbbbbbbbbbbb");
ftp_pasv($con,true);
$rootpath = "in"; // this is the root path for the remote server-- VK
//$rootpat,,,,,,,,,,,,,,,,,,,,,,,,,,/";
ftp_chdir($con,$rootpath);
$sourcepath = realpath("nnnnnnnnnnnnnnnnnnnnn"); // this is the physical path of the source directory. actually u can also use the relative path. -- VK
$destination_dir_name = "in/"; // this directory name will only change the top most directory and not the inner one -- VK
rec_copy ($sourcepath, $destination_dir_name, $con); //copy files
if (function_exists("ftp_close")){ //close connection
ftp_close($con);
}
print "FTP completed!\n";
?>