PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : ftp upload via html formular



invis-eo
06-03-2005, 19:11
Hallo Leute

Ich mache für mein Backend eine directory-upload Funktion welche über ftp das zeugs hochschauffeln soll. Nun gibts da leider ein kleines Problem wo ich nicht mehr weiter weiss.

Er hat irgendein Problem mit dem Directory wechsel. Der passende Code sieht folgendermassen aus (natürlich sind $ftp_server,$ftp_user_name und $ftp_user_pass):



$name= strip_tags($_POST["gallery_name"]);
$srcrela = strip_tags($_POST["directory_name"]);
$srcroot = strip_tags($_POST["directory"]);


$ftproot = "/usr/local/psa/home/vhosts/mydomain/httpdocs/gallery";


// connect to the destination FTP & enter appropriate directories both locally and remotely
$ftpc = ftp_connect("ftp.mydomain.ch");
$ftpr = ftp_login($ftpc,"login","passwort");

if ((!$ftpc) || (!$ftpr)) { echo "FTP connection not established!"; die(); }
if (!chdir($srcroot)) { echo "Could not enter local source root directory."; die(); }
if (!ftp_chdir($ftpc,$ftproot)) { echo "Could not enter FTP root directory."; die(); }

// start ftp'ing over the directory recursively
ftpRec ($srcrela);

// close the FTP connection
ftp_close($ftpc);


}
?>






function ftpRec ($srcrela)
{
global $srcroot;
global $ftproot;
global $ftpc;
global $ftpr;

// enter the local directory to be recursed through
chdir($srcroot.$srcrela);

// check if the directory exists & change to it on the destination
if (!ftp_chdir($ftpc,$ftproot.$srcrela))
{
// remote directory doesn't exist so create & enter it
ftp_mkdir ($ftpc,$ftproot.$srcrela);
ftp_chdir ($ftpc,$ftproot.$srcrela);
}

if ($handle = opendir("."))
{
while (false !== ($fil = readdir($handle)))
{
if ($fil != "." && $fil != "..")
{
// check if it's a file or directory
if (!is_dir($fil))
{
// it's a file so upload it
ftp_put($ftpc, $ftproot.$srcrela.$fil, $fil, FTP_BINARY);
}
else
{
// it's a directory so recurse through it
if ($fil == "templates")
{
// I want the script to ignore any directories named "templates"
// and therefore, not recurse through them and upload their contents
}
else
{
ftpRec ($srcrela.$fil."/");
chdir ("../");
}
}
}
}
closedir($handle);
}
}
?>




die Fehlermeldung sieht wie folgt aus (die Fett markierte Zeile ist line 111 im code...):

Warning: chdir(): No such file or directory (errno 2) in /usr/local/psa/home/vhosts/drunkensailor.ch/httpdocs/admin/gallery_admin.php on line 111
Could not enter local source root directory.


nun, kann mir da jemand weiterhelfen?
es sieht so aus als ob er das directory auf meinem pc, von welchem aus die files hochgeladen werden, nicht ändern kann..
was muss man da tun?

vielen dank!

rkauskh
17-03-2005, 08:52
Hi

Besteht das Problem noch? Ich würde mal versuchen, $ftproot in "mydomain/httpdocs/gallery"; zu ändern.

MfG
rk

P.S.: Bitte unbedingt meine PM lesen!