|
|
|
@ -469,4 +469,57 @@ class AjaxController extends ThinkController{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function addfile()
|
|
|
|
|
{
|
|
|
|
|
$this->meta_title = '文档添加';
|
|
|
|
|
$template = I('t');
|
|
|
|
|
$template = $template ?: 'Partner/addfile';
|
|
|
|
|
return $this->display($template);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//处理上传图片
|
|
|
|
|
public function saveFile()
|
|
|
|
|
{
|
|
|
|
|
$path = '/Uploads/';
|
|
|
|
|
$upload = new \Think\Upload();// 实例化上传类
|
|
|
|
|
$upload->maxSize = 0 ;// 设置附件上传大小
|
|
|
|
|
$upload->exts = '';// 设置附件上传类型
|
|
|
|
|
$upload->rootPath = '.'.$path; // 设置附件上传根目录
|
|
|
|
|
$upload->savePath = ''; // 设置附件上传(子)目录
|
|
|
|
|
// 上传文件
|
|
|
|
|
$info = $upload->upload();
|
|
|
|
|
// dump($info);
|
|
|
|
|
if(!$info) {// 上传错误提示错误信息
|
|
|
|
|
$msg = $upload->getError();
|
|
|
|
|
$array= array('status' => 0, 'info' => $msg);
|
|
|
|
|
}else{// 上传成功
|
|
|
|
|
$array=array(
|
|
|
|
|
"info"=>"上传成功",
|
|
|
|
|
"status"=>1,
|
|
|
|
|
"file_path"=>$path.$info['file']['savepath'].$info['file']['savename'],
|
|
|
|
|
"file_name"=>$_POST['file_name'],
|
|
|
|
|
"file_type"=>$_FILES['file']['type'],
|
|
|
|
|
"file_size"=>$_FILES['file']['size'],
|
|
|
|
|
"upload_time"=>date("Y-m-d H:i:s",time())
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
$this->ajaxReturn($array);
|
|
|
|
|
}
|
|
|
|
|
//删除图片
|
|
|
|
|
public function delFile()
|
|
|
|
|
{
|
|
|
|
|
$id = $_REQUEST['id'];
|
|
|
|
|
$index = $_REQUEST['index'] ?: false;
|
|
|
|
|
$file_path = $_REQUEST['file_path'] ?: false;
|
|
|
|
|
if($id == 0){
|
|
|
|
|
//未存入数据库,不用管
|
|
|
|
|
unlink("./".$file_path);
|
|
|
|
|
$this->ajaxReturn(array(
|
|
|
|
|
'status' => 1,
|
|
|
|
|
'info' => "删除成功"
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
# code...
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|