<form enctype="multipart/form-data" action="<?php $_SERVER['PHP_SELF']?>?submit=1" method="post">
Upload small image: <input name="filename" type="file">
<input type="submit" value="Upload">
</form>
<?php
$path="uploadfile/"; //上传路径
if(!file_exists($path))
{
//检查是否有该文件夹,如果没有就创建,并给予最高权限
mkdir("$path", 0700);
}
$tp = array("image/gif","image/pjpeg","image/jpeg","image/png");
if(!in_array($_FILES["filename"]["type"],$tp))
{
//echo "图片格式不正确!";
}
else
{
if($_FILES["filename"]["name"])
{
$file1=$_FILES["filename"]["name"];
//$file2 = $path.time().$file1;
//文件名称 取原文件名
$file2 = $path.$file1;
}
$result=move_uploaded_file($_FILES["filename"]["tmp_name"],$file2);
//特别注意这里传递给move_uploaded_file的第一个参数为上传到服务器上的临时文件
}
?>
<?php
//echo("<br>");
//echo date("Y-m-d h:m:s"); //年月日时分秒
//echo("<br>");
//echo mktime(); //获取当前时间戳
//echo("<br>");
//echo time(); //年月日时分秒
//echo("<br>");
//echo date("Ymdhms"); //年月日时分秒
function GetRandStr($len)
{
$chars = array( "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" );
$charsLen = count($chars) - 1;
shuffle($chars);
$output = "";
for ($i=0; $i<$len; $i++)
{
$output .= $chars[mt_rand(0, $charsLen)];
}
return $output;
}
//echo "随机数".GetRandStr(4);
echo "<br>";
echo date("Ymdhms").GetRandStr(5);
echo "<br>";
echo date("Ymdhms").GetRandStr(5);
echo "<br>";
echo date("Ymdhms").GetRandStr(5);
echo "<br>";
echo date("Ymdhms").GetRandStr(5);
?>