>  기사  >  백엔드 개발  >  is_uploaded_file() 함수는 PHP의 함수입니다.

is_uploaded_file() 함수는 PHP의 함수입니다.

WBOY
WBOY앞으로
2023-09-07 09:37:021000검색

is_uploaded_file() 함수는 PHP의 함수입니다.

is_uploaded_file() 함수는 파일이 HTTP POST를 통해 업로드되었는지 확인합니다. 이 함수는 파일이 HTTP POST를 통해 업로드된 경우 TRUE를 반환합니다. 실패 시 FALSE를 반환합니다.

Syntax

is_uploaded_file(file_path)

Parameters

  • file_path -확인할 파일을 지정합니다.

반환

파일이 HTTP POST를 통해 업로드되면 is_uploaded_file() 함수는 TRUE를 반환합니다. 실패 시 FALSE를 반환합니다.

다음 내용이 포함된 "new.txt" 파일을 업로드한다고 가정해 보겠습니다.

This is demo text!

Example

<?php
   // checking for file is uploaded via HTTP POST
   if (is_uploaded_file($_FILES[&#39;userfile&#39;][&lsquo;new.txt&#39;])) {
      echo "File ". $_FILES[&#39;userfile&#39;][&lsquo;new.txt&#39;] ." uploaded successfully!</p><p>";
      // displaying contents of the uploaded file
      echo "Reading Contents of the file:</p><p>";
      readfile($_FILES[&#39;userfile&#39;][&lsquo;new.txt&#39;]);
   } else {
      echo "File ". $_FILES[&#39;userfile&#39;][&lsquo;new.txt&#39;] ." failed in uploading! File upload attack could       be the reason!</p><p>";
   }
?>

Output

File new.txt uploaded successfully!
Reading Contents of the file:
This is demo text!

"details.txt" 파일이 포함된 또 다른 예를 살펴보겠습니다.

Example

Live Demo

<?php
$file = "newdetailstxt";
if(is_uploaded_file($file)) {
   echo ("Uploaded via HTTP POST");
} else {
   echo ("Not uploaded via HTTP POST");
}
?>

Output

Not uploaded via HTTP POST!

위 내용은 is_uploaded_file() 함수는 PHP의 함수입니다.의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 tutorialspoint.com에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제