20,359
社区成员
发帖
与我相关
我的任务
分享
<?php
class upload extends common{
public function __construct(){
parent::__construct();
}
public function index(){
//保存目录
$upload_save_path = C('UPLOAD_SAVE_PATH') ? C('UPLOAD_SAVE_PATH') : '../uploads/';
//上传目录
$upload_path = trim($_GET['dir'])=='' ? 'image' : trim($_GET['dir']);
//定义上传的文件扩展名
$ext_type = C('UPLOAD_ALLOW_TYPE');
if (empty($ext_type)){
$ext_type = array(
'IMAGE' => array('gif', 'jpg', 'jpeg', 'png', 'bmp'),
'MEDIA' => array('swf', 'flv', 'mp3','mp4','f4v','wav', 'wma', 'wmv', 'mid', 'avi', 'mpg', 'asf', 'rm', 'rmvb'),
'FILE' => array('doc', 'docx', 'xls', 'xlsx', 'zip', 'rar', 'gz', 'bz2','pdf'),
);}
//允许上传文件大小
$file_size = C('UPLOAD_ALLOW_SIZE')=='' ? 2097152 : C('UPLOAD_ALLOW_SIZE');
$upload = new uploads($upload_save_path.$upload_path.'/'.date("Ymd"),$ext_type[strtoupper($upload_path)],$file_size);
$uplofile = $upload->upload();
if($uplofile){
if (C('WATER_ON') && in_array($uplofile[0]['ext'],$ext_type['IMAGE'])){
$water = new image();
$water->water($uplofile[0]['path']);
}
if (C('THUMB_ON') && in_array($uplofile[0]['ext'],$ext_type['IMAGE'])){
$thumb = new image();
$thumb->thumb($uplofile[0]['path']);
}
echo json_encode(array('error' => 0, 'url' =>ltrim($uplofile[0]['path'],'..')));
}else{
$this->error($upload->getError());
}
}
}
$upload_save_path = C('UPLOAD_SAVE_PATH') ? C('UPLOAD_SAVE_PATH') : '../uploads/';
改成
$upload_save_path = 'uploads/';
就可以了