About a file upload code for php beginners (13 ). It is very useful to create a file upload form that allows users to upload files from the form. It is very useful to create a file upload form that allows users to upload files from the form. See create a file upload form below
It is very useful to allow users to upload files from forms.
Create a file upload form
It is very useful to allow users to upload files from forms.
See the following html form for uploading files:
The code is as follows:
Pay attention to the following information about this form:
The enctype attribute of a tag specifies the content type to be used when submitting a form. When a form requires binary data, such as file content, use multipart/form-data ".
The type = "file" attribute of the tag specifies that the input should be processed as a file. For example, when previewing in a browser, a browser button is displayed next to the input box.
Note: allowing users to upload files is a huge security risk. Only trusted users are allowed to upload files.
Create Upload script
The "upload_file.php" file contains the code for uploading files:
The code is as follows:
If ($ _ files ["file"] ["error"]> 0)
{
Echo "error:". $ _ files ["file"] ["error"]."
";
}
Else
{
Echo "upload:". $ _ files ["file"] ["name"]."
";
Echo "type:". $ _ files ["file"] ["type"]."
";
Echo "size:". ($ _ files ["file"] ["size"]/1024). "kb
";
Echo "stored in:". $ _ files ["file"] ["tmp_name"];
}
?>
1 2 3
It is very useful to allow users to upload files from forms. It is very useful to create a file upload form that allows users to upload files from the form. Please refer to the following...