thinkphp没有选择上传文件解决方案
时间:2021-07-01 10:21:17
帮助过:16人阅读
thinkphp 没有选择上传文件
文件上传
class UploadAction extends Action{
function index(){
$this->display();
}
public function upload(){
import('ORG.NET.UploadFile');
$upload = new UploadFile();
$upload->maxSize = 200000;
$upload->allowExts=array('jpg', 'gif', 'png', 'jpeg');
$upload->saveRule = uniqid;
$upload->savePath = './Public/Uploads/';
$upload->thumb = true;
$upload->thumbMaxWidth = 120 ;
$upload->thumbMaxHeight = 140;
$upload->thumbRemoveOrigin = false;
$upload->thumbPath ='./Public/Thumb/';
if($_FILES['myfile']['error'] > 0){
echo 'error';
}else{
echo "success";
}
if($upload->upload()){
$Info =$upload->getUploadFileInfo();
echo $Info;
}else{
echo $_FILES['myfile']['error'];
$this->Error($upload->getErrorMsg());
}
}
// 文件上传
}
总是显示没有选择上传文件,请问有知道是怎么回事的吗?
------解决方案--------------------
具体提示信息或者报错信息呢?
------解决方案--------------------
你看看你的html代码写好没?你的phpini开启没有?
------解决方案--------------------
mulitypart-form/data
应该是:multipart/form-data