文件上传 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());
}
}
// 文件上传
}
总是显示没有选择上传文件,请问有知道是怎么回事的吗?
回复讨论(解决方案)
具体提示信息或者报错信息呢?
操作失败!没有选择上传文件
页面将在 3 秒后自动跳转,如果不想等待请点击 这里 跳转
上面可以输出success这个单词
你看看你的html代码写好没?你的phpini开启没有?
mulitypart-form/data
应该是:multipart/form-data
我也遇到这个问题了 最后怎么解决的啊? 怎么没人回答呢
form 中增加 enctype="multipart/form-data"