PHP中的move_uploaded_file()函数
move_uploaded_file()函数将上传的文件移动到新位置。如果目标文件已经存在,它将被覆盖。
语法
move_uploaded_file(file_path, moved_path)
参数
file_path-要移动的文件。
moving_path-文件将被移动到的位置。
返回
move_uploaded_file()函数在成功时返回true,在失败时返回false。
示例
<?php
if (move_uploaded_file($_FILES['userfile']['tmp_name'], "/documents/new/")) {
print "上传成功!";
} else {
print "上传失败!";
}
?>输出结果
上传失败!PHP Notice: Undefined index: userfile in /home/cg/root/8944881/main.php on line 2