I have been busy with the transition from ASP to PhP recently. PHP is a lot easier to learn! Here is an example of File Upload. By the way, you can write down the learning logs. for complex operations, learn more...
Index. php program code on the form page <form method = "Post" Action = "Upload. php" enctype = "multipart/form-Data">
File: <input type = "file" name = "userfile"/>
<Input type = "Submit" value = "Upload File"/>
</Form>
Do not forget this sentence. enctype = "multipart/form-Data"
Upload page upload. asp. below isCode, Just two or three program codes <? PHP
If (move_uploaded_file ($ _ FILES ['userfile'] ['tmp _ name'], getcwd (). "\\". $ _ FILES ['userfile'] ['name'])
Echo "OK! ";
Else
Echo "failed! ";
?>
Get the uploaded file through the $ _ FILES array. Here, the userfile corresponds to the name attribute of the form, and $ _ FILES ['userfile'] ['name'] gets the name of the uploaded file, $ _ FILES ['userfile'] ['tmp _ name'] is a temporary file name for uploading files stored on the server. The getcwd () function obtains the directory of the current file, move_uploaded_file: Move the uploaded file to the specified position. The returned value is a Boolean value. If the operation succeeds, the file is uploaded successfully.