Home > Backend Development > PHP Problem > How to upload php files

How to upload php files

爱喝马黛茶的安东尼
Release: 2023-02-23 12:52:01
Original
3794 people have browsed it

How to upload php files

Relevant steps for uploading php files:

Create a new form for uploading files.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>上传文件</title>
</head>
<body>
<form action="upload_file.php" method="post" enctype="multipart/form-data">
<label for="file">Filename</label>
<input type="file" name="file" id="file"></br>
<input type="submit" value="提交"></br>
</form>
</body>
</html>
Copy after login

How to upload php files

Related recommendations: "PHP Getting Started Tutorial"

Create a new php file for processing files, first set the character set .

How to upload php files

If there is an error in the uploaded file, an error will be displayed.

How to upload php files

If there are no errors, the contents of the file will be displayed, starting with the name of the file.

How to upload php files

Display the size of the file.

echo "type:".$_FILES[&#39;file&#39;][&#39;type&#39;]."<br/>";
Copy after login

How to upload php files

Display the size of the file and the location of temporary storage.

How to upload php files

Test in the browser.

The complete code is as follows:

0){
echo $_FILES['file']['error']."
"; } else{ echo "uoload:".$_FILES['file']['name']."
"; echo "type:".$_FILES[&#39;file&#39;][&#39;type&#39;]."<br/>"; echo "size:".$_FILES['file']['size']."
"; echo "store in:".$_FILES['file']['tmp_name']."
"; } ?>
Copy after login

How to upload php files

The above is the detailed content of How to upload php files. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template