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

WBOY
풀어 주다: 2023-09-07 09:38:02
앞으로
999명이 탐색했습니다.

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으로 문의하세요.
최신 이슈
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!