Jehna :)

PHP 업로드 파일 삭제 본문

윌리/PHP

PHP 업로드 파일 삭제

Jehna 2022. 5. 9. 17:37

 환경

     CentOS7.x /  php 7.3 

 

opendir로 삭제하려는 파일이 위치한 디렉토리를 열고 unlink로 파일 삭제!

생각보다 쉽고 간단합니당~

// 파일 경로 선언
$upload_path = $_SERVER['DOCUMENT_ROOT']."/test/";

// 파일이 위치한 디렉토리 열기
if ( opendir($upload_path) ) {
    @unlink($upload_path."파일명.txt");
}

 

'윌리 > PHP' 카테고리의 다른 글

[PHP] Class 'ZipArchive' not found 에러  (0) 2022.07.21