Fungsi
is_uploaded_file() menyemak sama ada fail telah dimuat naik melalui HTTP POST. Fungsi ini mengembalikan TRUE jika fail telah dimuat naik melalui HTTP POST. Mengembalikan FALSE pada kegagalan.
is_uploaded_file(file_path)
file_path -Nyatakan fail untuk disemak.
Jika fail dimuat naik melalui HTTP POST, fungsi is_uploaded_file() akan mengembalikan BENAR. Mengembalikan FALSE pada kegagalan.
Katakan kami memuat naik fail "new.txt" dengan kandungan berikut.
This is demo text!
<?php // checking for file is uploaded via HTTP POST if (is_uploaded_file($_FILES['userfile'][‘new.txt'])) { echo "File ". $_FILES['userfile'][‘new.txt'] ." uploaded successfully!</p><p>"; // displaying contents of the uploaded file echo "Reading Contents of the file:</p><p>"; readfile($_FILES['userfile'][‘new.txt']); } else { echo "File ". $_FILES['userfile'][‘new.txt'] ." failed in uploading! File upload attack could be the reason!</p><p>"; } ?>
File new.txt uploaded successfully! Reading Contents of the file: This is demo text!
Mari kita lihat contoh lain dengan fail "details.txt".
Live Demo
<?php $file = "newdetailstxt"; if(is_uploaded_file($file)) { echo ("Uploaded via HTTP POST"); } else { echo ("Not uploaded via HTTP POST"); } ?>
Atas ialah kandungan terperinci Fungsi is_uploaded_file() ialah fungsi dalam PHP. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!