php图片、文件上传
时间:2011-04-13 来源:狼问苍穹
1 if ($_FILES['img']['tmp_name']) {
2 if ($_FILES['img']['size'] > 1000000) {
3 $ctp->alert("错误:图片过大!");
4 $ctp->goto("manage.php?type=active_add&id={$id}");
5 }
6 if (! in_array($_FILES['img']['type'], array('image/pjpeg', 'image/gif', 'image/x-png'))) {
7 $ctp->alert("错误:请上传jpeg/jif/png格式的图片!");
8 $ctp->goto("manage.php?type=active_add&id={$id}");
9 }
10 $typeArr = array('image/pjpeg' => '.jpg', 'image/gif' => '.gif', 'image/x-png' => '.png');
11 $uploadDir = 'uploads/active/'.date('YmdHis').$typeArr[$_FILES['img']['type']];
12 move_uploaded_file($_FILES['img']['tmp_name'], $uploadDir);
13 }
2 if ($_FILES['img']['size'] > 1000000) {
3 $ctp->alert("错误:图片过大!");
4 $ctp->goto("manage.php?type=active_add&id={$id}");
5 }
6 if (! in_array($_FILES['img']['type'], array('image/pjpeg', 'image/gif', 'image/x-png'))) {
7 $ctp->alert("错误:请上传jpeg/jif/png格式的图片!");
8 $ctp->goto("manage.php?type=active_add&id={$id}");
9 }
10 $typeArr = array('image/pjpeg' => '.jpg', 'image/gif' => '.gif', 'image/x-png' => '.png');
11 $uploadDir = 'uploads/active/'.date('YmdHis').$typeArr[$_FILES['img']['type']];
12 move_uploaded_file($_FILES['img']['tmp_name'], $uploadDir);
13 }
相关阅读 更多 +