function ftp_upfile($source, $file, $ifdel = 1) { global $webdb; if (!$webdb[FtpHost] || !$webdb[FtpName] || !$webdb[FtpPwd] || !$webdb[FtpPort] || !$webdb[FtpDir]) { return; } require_once ROOT_PATH . "inc/ftp.php"; $ftp = new FTP($webdb[FtpHost], $webdb[FtpPort], $webdb[FtpName], $webdb[FtpPwd], $webdb[FtpDir]); $path = dirname($file); $detail = explode("/", $path); //$pathname=$webdb[FtpDir]; foreach ($detail as $key => $value) { $pathname .= "{$value}/"; if (!$ftp->dir_exists($pathname)) { $ftp->mkd($pathname); } } $ifput = $ftp->upload($source, $file); $ftp->close(); if ($ifput) { $ifdel && unlink($source); return "{$webdb['mirror']}/{$file}"; } else { return "{$webdb['www_url']}/{$webdb['updir']}/{$file}"; } }