上传图片的完整程序
//页面显示
">
//upload.php文件
//upfile.php文件
$pic_name=$_FILES['photo']['tmp_name'];
$time=time();
$dir=date("y-m",$time);
if ($pic_name!="")
{
if ($_FILES['photo']['type']=="image/pjpeg" || $_FILES['photo']['type']=="image/jpeg")
{
$photo_name=time() . ".jpg";
$photodir="../../photo/$dir/";
if(!(file_exists($photodir) and is_dir($photodir)))
{
mkdir($photodir,0777);
}
@move_uploaded_file($_FILES['photo']['tmp_name'],$photodir.$photo_name);
}elseif($_FILES['photo']['type']=="image/gif")
{
$photo_name=time() . ".gif";
$photodir="../../photo/$dir/";
if(!(file_exists($photodir) and is_dir($photodir)))
{
mkdir($photodir,0777);
}
@move_uploaded_file($_FILES['photo']['tmp_name'],$photodir.$photo_name);
} else{
echo "";
exit;
}
}else{
$photo_name="";
}
$pic="/photo/$dir/$photo_name";
echo "";