me102 Posted November 28, 2010 Share Posted November 28, 2010 Hello I am having a little bit of a problem when I try to upload a directory and its subdirectorys i keep getting errors because the done exist but how would I go about making them, This is what I have, <?php //Source Files, Where to put them $src_dir = "/source_codes/"; $dst_dir = "/haha/"; // Start the ftp connection $conn_id = ftp_connect($ftp_server) or die("<span style='color:#FF0000'><h2>Couldn't connect to $ftp_server</h2></span>"); $login_result = ftp_login($conn_id, $user, $passwd); // check connection if ((!$conn_id) || (!$login_result)) { echo "FTP connection has failed!"; echo "Attempted to connect to $ftp_server for user $ftp_user_name"; die; } else { echo "<br>Connected to $ftp_server, for user $user<br>"; } function ftp_copy($src_dir, $dst_dir) { global $conn_id; $d = dir($src_dir); while($file = $d->read()) { if ($file != "." && $file != "..") { if (is_dir($src_dir."/".$file)) { if (!@ftp_chdir($conn_id, $dst_dir."/".$file)) { ftp_mkdir($conn_id, $dst_dir."/".$file); } ftp_copy($src_dir."/".$file, $dst_dir."/".$file); }else { $upload = ftp_put($conn_id, $dst_dir."/".$file, $src_dir."/".$file, FTP_BINARY); // check upload status if (!$upload) { echo "FTP upload has failed!"; } else { echo "Uploaded $source_file to $ftp_server as $destination_file"; } } } } $d->close(); } ftp_copy($src_dir, $dst_dir); // close the FTP stream ftp_close($conn_id); ?> Link to comment https://forums.phpfreaks.com/topic/220051-php-ftp/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.