PHP页面
// include 'templates/init.php'; //什么东西
//初始化act
$_REQUEST['act']=$_REQUEST['act']?$_REQUEST['act']:'';
if($_REQUEST['act']=='add'){
include 'templates/tupian_add.php';
}elseif($_REQUEST['act']=='insert'){ //文件上传
$brand=$_FILES['logo'];
if($brand['error']==0){
//判断用户提交的图片格式是否是我要求的格式
$allow_type=array('image/gif','image/jpeg','image/png','image/pjpeg');
if(in_array($brand['type'],$allow_type)){
//符合要求
//在判断提交的大小
$max_size=20000000;
if($brand['size']<=$max_size){
//容许上传到服务器
$new_file_name=time().mt_rand(10000,99999).strrchr($brand['name'],'.');//新文件夹
move_uploaded_file($brand['tmp_name'],'file_photos/'.$new_file_name);
//var_dump($new_file_name);
$brand_logo='file_photos/'.$new_file_name;
//var_dump($title,$content,$time);
include 'db.class.php';
$db=new db('localhost','root','123','fanyi');
$sql="insert into tupian values(null,'$brand_logo')";
if(mysql_query($sql)){
echo "图片添加成功";
//header("Refresh: 2; url=http://localhost/admin/brand.php?act=list");
}
}
}
}
}
-----------------------------------------------------------------------------------------------------------------
HTML页面
图片LOGO | 请上传图片 |