帮小弟我看看这个代码,修改功能,无法修改附件。其他正常修改。post方式提交
程序员文章站
2024-02-15 10:47:58
...
帮我看看这个代码,修改功能,无法修改附件。其他正常修改。post方式提交
修改功能,无法修改附件。其他正常修改。form表单 ,post方式提交。附件为attachments
public function do_update(){
$admin =M('record');
$id = $_POST['id'];
$map2['id'] = $id;
$content= $_POST['content'];
$map['content'] = $content;
$title = $_POST['title'];
$map['title'] = $title;
//文件上传
import('ORG.Net.UploadFile');
$upload = new UploadFile();// 实例化上传类
$upload->maxSize = 3145728 ;// 设置附件上传大小
if($_FILES['attachments']){
$upload = new UploadFile();// 实例化上传类
$upload->maxSize = 3145728000 ;// 设置附件上传大小
//$upload->allowExts = array('jpg', 'gif', 'png', 'jpeg','txt','doc','doxc','wps','xls','pdf','txt');// 设置附件上传类型
$upload->savePath = './Public/Uploads/';// 设置附件上传目录
$upload->supportMulti = false;
$upload->autoSub = false;
$info = $upload->uploadOne($_FILES['attachments']);
$map['attachments'] = $info[0]['savename'];
}
$result=$admin->where($map2)->save($map);
$this->redirect('__URL__/Admin/admin');
}
------解决方案--------------------
在$result上面打印$map,看一下attachments的值,对应查看表中的字段类型,和长度,这个应该是TP框架,最近没在用,最近在研究CI
修改功能,无法修改附件。其他正常修改。form表单 ,post方式提交。附件为attachments
public function do_update(){
$admin =M('record');
$id = $_POST['id'];
$map2['id'] = $id;
$content= $_POST['content'];
$map['content'] = $content;
$title = $_POST['title'];
$map['title'] = $title;
//文件上传
import('ORG.Net.UploadFile');
$upload = new UploadFile();// 实例化上传类
$upload->maxSize = 3145728 ;// 设置附件上传大小
if($_FILES['attachments']){
$upload = new UploadFile();// 实例化上传类
$upload->maxSize = 3145728000 ;// 设置附件上传大小
//$upload->allowExts = array('jpg', 'gif', 'png', 'jpeg','txt','doc','doxc','wps','xls','pdf','txt');// 设置附件上传类型
$upload->savePath = './Public/Uploads/';// 设置附件上传目录
$upload->supportMulti = false;
$upload->autoSub = false;
$info = $upload->uploadOne($_FILES['attachments']);
$map['attachments'] = $info[0]['savename'];
}
$result=$admin->where($map2)->save($map);
$this->redirect('__URL__/Admin/admin');
}
------解决方案--------------------
在$result上面打印$map,看一下attachments的值,对应查看表中的字段类型,和长度,这个应该是TP框架,最近没在用,最近在研究CI
相关文章
相关视频