In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Today, I will talk to you about how to use file functions to upload PHP files. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
If you are a computer enthusiast and don't know PHP, you are too out of date. If you want to know about PHP, let's take a look at the implementation of PHP file upload. This code is divided into two files, one is upload.html and the other is upload.php.
Among them, please note that this is a tag, we want to achieve file upload, must be specified as multipart/form-data, otherwise the server will not know what to do. It is worth noting that the hidden range of the form option MAX_FILE_SIZE in the file upload.html can limit the size of the uploaded file by setting its Value (value). The value of MAX_FILE_SIZE is just a suggestion for browsers, which can actually be simply bypassed. So don't pin your browser restrictions on this value. In fact, the PHP file in the PHP setting will not be invalidated when uploading the * * value. But * add MAX_FILE_SIZE to the form because it avoids the hassle of users spending time waiting for a large file to be uploaded before they find it too big.
Upload.php $f=&$HTTP_POST_FILES ['Myfile']; $dest_dir='uploads';// set the upload directory $dest=$dest_dir.'/'.date ("ymd"). "_". $f [' name']; / / set the file name to the date plus the file name to avoid repeating $r=move_uploaded_file ($f ['tmp_name'], $dest); chmod ($dest, 0755); / / set the properties of the uploaded file
Or
The contents of the $_ FILES array in the above example are shown below. We assume that the name of the file upload field is userfile (name can be arbitrarily named)
$_ FILES ['userfile'] [' name'] / / the original name of the client machine file. The MIME type of $_ FILES ['userfile'] [' type'] / / file, which requires the browser to provide support for this information, such as "image/gif". $_ FILES ['userfile'] [' size'] / / the size of the uploaded file in bytes. $_ FILES ['userfile'] [' tmp_name'] / / the temporary file name stored on the server after the file is uploaded. $_ FILES ['userfile'] [' error'] / / error code related to the upload of this file
PHP file upload value analysis:
◆ value: 0; No error occurred, and the file was uploaded successfully.
The ◆ value: 1; the uploaded file exceeds the limit of the upload_max_filesize option in php.ini.
The ◆ value: 2; the size of the uploaded file exceeds the value specified by the MAX_FILE_SIZE option in the HTML form.
◆ value: 3; only part of the file has been uploaded.
◆ value: 4; No files have been uploaded.
After reading the above, do you have any further understanding of how to use file functions to upload PHP files? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.