File Upload implementation
If you are familiar with ASP, you may know that it is not easy to upload files using ASP. PHP is different and easier. For example, send.htm and get. php are as follows:
<! --File send.htm -->
<Form ENCTYPE = "multipart/form-data" ACTION = "get. php" METHOD = post>
<Input type = "hidden" name = "MAX_FILE_SIZE" value = "1000">
Send this file: <input name = "userfile" TYPE = "file">
<Input type = "submit" VALUE = "Send File">
</Form>
The following code receives uploaded files
<? Php
# File get. php
If (rename ($ userfile, "\ dir \ upload. dat )"){
Echo "successful! ";
}
Else {
Echo "Upload Failed! ";
}
?>
Note:
I. The upload_tmp_dir file in the php. ini file is used to describe the temporary directory of the files uploaded by PHP.
2. If the uploaded files stored in the temporary directory are not moved or renamed, they will be deleted immediately.
3. You must have the write permission on the directory for uploading files.
Last suggestion: Do not allow users to upload executable files, or set the file to be unexecutable. You should know why