How to implement file upload in php
1. Create a form and file type input and set the form attribute "enctype" to "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. Save the submitted file through the "move_uploaded_file" function in the PHP program.
$filename = $file_tmp = $_FILES['upfile']['name']; $file_tmp = $_FILES['upfile']['tmp_name']; move_uploaded_file($file_tmp, 'Uploads/' . $filename);
The above is the detailed content of PHP file upload method. For more information, please follow other related articles on the PHP Chinese website!