순지난의 좋은선물



CATEGORY

분류 전체보기 (62)
아이폰 (5)
안드로이드 (2)
PHP (7)
IT 팁 (13)
snoopy.class (8)
sencha (0)
PhoneGap (0)
jQuery (2)
리눅스 (4)
즐겨찾기 (2)
js (1)
Html &CSS (6)
wowza (1)
모바일웹 (1)
ajax (0)
mysql (1)
apps (5)
corona sdk (1)

RECENT ARTICLE

RECENT COMMENT

RECENT TRACKBACK

ARCHIVE

LINK



  1. 2011.06.16
    FTP 원격으로 파일 업로드 / 삭제

$server_host_1="test.net"; //-->원격서버의 ip주소
$server_port="21"; //-->원격서버의 port
$server_id="test"; //-->원격서버의 서버id
$server_pw="testpwd"; //-->원격서버의 서버password

//원격서버에 연결한다.
if(!($fc_1 = ftp_connect($server_host_1, $server_port))) die("$server_host : $server_post - connect failed");

//원격서버에 로그인한다.
if(!ftp_login($fc_1, $server_id, $server_pw)) die("$server_id - login failed");

//업로드할 폴더로 이동한다.
$server_dir = "/home/public_html/test/";
ftp_chdir($fc_1, $server_dir);

//파일을 업로드 한다.
if(!ftp_put($fc_1, $upload_img_name, $upload_img, FTP_BINARY))
{

echo" <script name=javascript> window.alert ('파일을 지정한 디렉토리로 복사 하는 데 실패했습니다._1');
//history.go(-1)
</script>";
exit;

}

//FTP를 닫는다
ftp_quit($fc_1);

[출처] 세이박스 - http://www.saybox.co.kr/bbs/board.php?bo_table=board02&wr_id=14


파일업로드시 큰 용량 업로드 문제가 발생할때는 실행제한 시간이 걸려서 그렇습니다.
php.ini에서 max_execution_time 값을 바꾸면 됩니다
set_time_limit(0) 이 명령어를 실행시키면 실행시간을 무제한으로 만들수 있습니다...
----------------------------------------------------------------------------------------
삭제방법
------------------------------------------------------------------------------------------
$ftp_server_1="test.net";
$ftp_user_name="test";
$ft_user_pass="testpwd";

$file = "/home/public_html/test/".$pre_file;

//set up basic connection
$conn_id= ftp_connect($ftp_server_1);

//login width username and pasword
$login_result_1=ftp_login($conn_id,1,$ftp_use_namem$ftp_user_pass);

//tr to delte $file
$ftp_delete($conn_id,$file);
//clods the connection
$file_quit($conn_id_1);


//Create a directory 'config' at the root of your website
@ftp_mkdir($ftpstream, '/public_html/config');

//Make the file writable by all
ftp_site($ftpstream,"CHMOD 0777 /public_html/config/config.inc");

//Write to file
$fp = fopen('/home/jatinder/public_html/config/config.inc', 'w');
fputs($fp,'Learnt this at PHPSense.com');
fclose($fp);

//Make the file writable only to owner
ftp_site($ftpstream,"CHMOD 0644 /public_html/config/config.inc");

And