In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
Create a new 1107.php file and write the following code in the file:
File upload
Select a file:
Create a new t2.php file and write the following code in the file:
$allowtype=array ("gif", "png", "jpg"); / / sets the types of files allowed to be uploaded
$size=1000000; / / sets the file size allowed to upload
$path= ". / uploads"; / / set the path to save the file after uploading
/ / determine whether the file can be successfully uploaded to the server. If $_ FILES ["myfile"] ["error"] is 0, the file can be uploaded successfully.
If ($_ FILES ["myfile"] ["error"] > 0) {
Echo "File upload error"
Switch ($_ FILES ["myfile"] ["error"]) {
Case 1:die ("upload file size exceeds the agreed value in the PHP configuration file"); break
Case 2:die ("upload file size exceeds the agreed value in the form"); break
Case 3:die ("the file is only partially uploaded"); break
Case 4:die ("No files uploaded"); break
Default: die (unknown error); break
}
}
/ / determine whether the uploaded file is an allowed type by the suffix name of the file.
$hz=array_pop (explode (".", $_ FILES ["myfile"] ["name"]))
If (! in_array ($hz,$allowtype)) {
Die ("this file suffix is {$hz}, not the allowed file type!")
}
/ / determine whether the uploaded file is the allowed size
If ($_ FILES ["myfile"] ["name"] > $size) {
Die ("exceeds the allowed {$size} byte size")
}
/ / for the sake of system security and not to overwrite the file with the same name, use the system definition after uploading the file name
$filename=date ("YmdHis"). Rand (100999). ". $hz
/ / determine whether the file is uploaded
If (is_uploaded_file ($_ FILES ["myfile"] ["tmp_name"]) {
If (! move_uploaded_file ($_ FILES ["myfile"] ["tmp_name"], $path. "/". $filename) {
Die ("problem: cannot move files to the specified directory")
}
} else {
Die ("problem: uploading file {$_ FILES [" myfile "] [" name "]} is not a legal file!)
}
/ / output if the file is uploaded successfully
Echo "File {$upfile} uploaded successfully and saved in directory {$path} with a file size of {$_ FILES [" myfile "] [" size "]} bytes"
To execute the above example, you need to create a uploads directory (that is, a folder) in the current directory!
The die () function outputs a message and exits the current script
This function is an alias for the exit () function.
The syntax die (status) parameter describes the status required. Specifies the message or status number written before exiting the script. The status number is not written to the output. Description
If status is a string, the function outputs the string before exiting.
If status is an integer, this value is used as the exit state. The value of the exit status is between 0 and 254. The exit status of 255 is reserved by PHP and will not be used. Status 0 is used to successfully terminate the program.
Tips and comments: if the version number of PHP is greater than or equal to 4.2.0, this parameter will not be output if status is an integer.
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.