move_uploaded_file() 函數將上傳的文件移動到新位置。如果目標文件已經存在,它將被覆蓋。
用法
move_uploaded_file(file_path, moved_path)
參數
file_path −要移動的文件。
moved_path −文件將被移動到哪裏。
返回
move_uploaded_file() 函數在成功時返回 true,在失敗時返回 false。
示例
<?php
if (move_uploaded_file($_FILES['userfile']['tmp_name'], "/documents/new/")) {
print "Uploaded successfully!";
} else {
print "Upload failed!";
}
?>
輸出
Upload failed!PHP Notice:Undefined index:userfile in /home/cg/root/8944881/main.php on line 2
相關用法
- PHP money_format()用法及代碼示例
- PHP metaphone()用法及代碼示例
- PHP mhash_get_hash_name()用法及代碼示例
- PHP mysqli_get_server_info()用法及代碼示例
- PHP mysqli_data_seek()用法及代碼示例
- PHP mysqli_insert_id()用法及代碼示例
- PHP mysqli_fetch_assoc()用法及代碼示例
- PHP mkdir()用法及代碼示例
- PHP mysqli_connect_error()用法及代碼示例
- PHP mhash_keygen_s2k()用法及代碼示例
- PHP microtime()用法及代碼示例
- PHP mysqli_fetch_all()用法及代碼示例
- PHP mt_rand( )用法及代碼示例
- PHP mysqli_next_result()用法及代碼示例
- PHP mysqli_stmt_affected_rows()用法及代碼示例
- PHP mime_content_type()用法及代碼示例
- PHP mysqli_begin_transaction()用法及代碼示例
- PHP mysqli_real_escape_string()用法及代碼示例
- PHP mysqli_fetch_lengths()用法及代碼示例
注:本文由純淨天空篩選整理自Karthikeya Boyini大神的英文原創作品 move_uploaded_file() function in PHP。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。