</body>
3.uploadclass.php
<?php
$uploaddir = "upfiles/";//settings File Save directory Note contains/
$type =array ("JPG", "gif", "BMP", "JPEG", "PNG");//Set the type of file allowed to be uploaded
$patch = "upload/";//program Path
Get file suffix name function
function Fileext ($filename)
{
Return substr (STRRCHR ($filename, '. '), 1);
}
Generate a random file name function
function Random ($length)
{
$hash = ' cr-';
$chars = ' abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz ';
$max = strlen ($chars)-1;
Mt_srand (Double) microtime () * 1000000);
for ($i = 0; $i < $length; $i + +)
{
$hash. = $chars [Mt_rand (0, $max)];
}
return $hash;
}
$a =strtolower (fileext ($_files[' file ' [' name '])];
Determining File Types
if (Strtolower (Fileext ($_files[' file ' [' name ']), $type))!in_array
{
$text =implode (",", $type);
echo "You can only upload the following types of files:", $text, "<br>";
}
Generate file name for target file
else{
$filename =explode (".", $_files[' file '] [' name ']);
Todo
{
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.