Dynamic Web development, commonly used PHP upload file code example.
Web page Teaching Network (webjx.com) file upload instance
function GetName ($exname) {
$dir = ". /previousfile/";
$i = 1;
if (!is_dir ($dir)) {
mkdir ($dir, 0777);
}
while (true) {
if (!is_file ($dir. $i. ".". $exname)) {
$name = $i. ".". $exname;
Break
}
$i + +;
}
return $dir. $name;
}
$exname =strtolower (substr ($_files[upfile][name], (Strrpos ($_files[upfile][name),.) +1)));
$PreviousFile = GetName ($exname);
if (Move_uploaded_file ($_files[upfile][tmp_name], $PreviousFile)) {
echo "
File Upload Successful!
";
}else {
echo "
File upload failed!
";
}
echo "Here are some information about file uploads:
Original file name: ". $_files[upfile][name].
"
Type: ". $_files[upfile][type].
"
Temp file name: ". $_files[upfile][tmp_name].
"
File size: ". $_files[upfile][size].
"
Error code: ". $_files[upfile][error";
?>
http://www.bkjia.com/PHPjc/531665.html www.bkjia.com true http://www.bkjia.com/PHPjc/531665.html techarticle Dynamic Web development, commonly used PHP upload file code example. HTML head meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "Title Web Teaching Network (webjx.com) file ...