답변 1개
새싹반일진
12년 전
아래코드를 참조해보세요
// 다른서버로 업로드 함
function ftp_upload($ori_img,$new_img)
{
$source_file = $this -> dir.$ori_img; // 원래 저장된 폴더의 경로와 파일명(상대 경로)
$target_file = $new_img."_upfile"; // ftp에 업로드할 파일명
$ftp_server = $this -> ftp_server;
$user = $this -> ftp_user;
$pass = $this -> ftp_pass;
$port = $this -> ftp_port;
$chdir = $this -> ftp_dir;
$mode = FTP_BINARY; // mode
$conn_id = ftp_connect($ftp_server,$port);
if($conn_id)
{
$login_result = ftp_login($conn_id,$user,$pass);
}
if((!$conn_id) || (!$login_result))
{
echo "Ftp connect has Failed !<br>";
echo "Try again!";
return;
} else {
$dir = ftp_chdir($conn_id,$chdir) or die ('디렉토리 변경 실패');
$up = ftp_put($conn_id, $target_file ,$source_file ,$mode) or die ('upload 실패');
// 접속 , 업로드될파일,원본 파일명 ,모드
}
$ftp[img] = $this -> ftp_dir.$target_file;
$ftp[server] = $ftp_server;
return $ftp;
}// end of ftp_upload
답변을 작성하려면 로그인이 필요합니다.