In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to understand the main code for uploading PHP files". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to understand the main code for uploading PHP files".
The copy code is as follows:
Description:
Before we explain this code, we need to know the following.
$_ FILES ['myfile'] [' name'] refers to the name of the file being uploaded
$_ FILES ['myfile'] [' type'] refers to the type of file being uploaded
$_ FILES ['myfile'] [' size'] refers to the size of the uploaded file in bytes (B)
$_ FILES ['myfile'] [' tmp_name'] refers to the name of the temporary copy of the uploaded file stored on the server. The file will be destroyed automatically after the file is moved to the specified directory.
$_ FILES ['myfile'] ["error"] refers to the status code of errors that may occur in the file upload. The meaning of each state will be explained later.
With this in mind, let's take a look at the upload.php code again.
First of all, the myfile in $_ FILES ['myfile'] [' name'] refers to the name value of the file tag uploaded in the above HTML page, so that we can know which input submitted the file we are working on.
Then let's determine whether $_ FILES ['myfile'] [' name'] is empty, according to which we can know whether the user has uploaded the file or not, thus performing different operations.
If the uploaded file is successfully uploaded and the status is 0, we can use the move_uploaded_file method to store the uploaded file in the specified directory. In the above example, the uploaded file is moved to the uploads folder in the same directory. This path is relative to the PHP file (i.e. upload.php).
For example, if we want to move the uploaded file to a folder called user above the upload.php, we can write: move_uploaded_file ($_ FILES ['myfile'] [' tmp_name'], ". / user/". FILES ['myfile'] [' name']), this method is very convenient and flexible, so that a file is uploaded to the server, and you can open a directory in the server to view the file.
Thank you for your reading, the above is the content of "how to understand the main code for uploading PHP files". After the study of this article, I believe you have a deeper understanding of how to understand the main code for uploading PHP files. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.