- <?php
- $newfile = '11.txt';
- $copyfile = '33.txt';
- // $newfile 파일 생성
- $fmodify_w = fopen($newfile, "w");
- fputs($fmodify_w, "파일추가");
- fclose($fmodify_w);
- // $copyfile 파일 복사
- if(copy($newfile, $copyfile)){
- echo "파일 복사 완료<br>\n";
- // 복사한 파일 내용 확인
- $fmodify_r = fopen($copyfile, "r");
- echo fgets($fmodify_r )."<br>\n";
- fclose($fmodify_r );
- }
- else{
- echo "파일 복사 실패<br>\n";
- }
- // 파일 리스트 확인
- system("ls");
- // ls는 리눅스에서 파일 리스트 출력 명령어 입니다.
- // 11.txt 33.txt
- /* 방법2
- system("cp -f 11.txt 33.txt");
- 즉 리눅스 명령어로 바로 복사하는 방법도 있습니다.
- 출력은 위와 동일합니다.
- */
- ?>
--------------------------------------------------------------------------------------------
bool copy ( string $source , string $dest [, resource $context ] )
11. 라인
로컬 시스템에 파일을 복사합니다.
'php5 > 파일관련함수' 카테고리의 다른 글
파일 사용시 접근 잠금 - bool flock ( resource $handle , int $operation ) (0) | 2014.01.10 |
---|---|
파일 존재 확인 - bool file_exists ( string $filename ) (0) | 2014.01.10 |
시스템 명령어 실행2 - string exec ( string $command ) (0) | 2014.01.10 |
시스템 명령어 실행1 - string system ( string $command ) (0) | 2014.01.10 |
파일 경로 반환 - string dirname ( string $path ) (0) | 2014.01.09 |