php如何实现文件上传
1、创建表单和file类型的input并将表单属性“enctype”设置为“multipart/form-data”;
<form action="./upload_file.php" method="post" enctype="multipart/form-data"> <input type="file" name="upfile"> <button type="submit">上传</button> </form>
2、在php程序中通过“move_uploaded_file”函数将提交的文件进行保存即可。
$filename = $file_tmp = $_FILES['upfile']['name']; $file_tmp = $_FILES['upfile']['tmp_name']; move_uploaded_file($file_tmp, 'Uploads/' . $filename);