Error when uploading file format error
**13
**13 2018-07-19 17:01:54
0
3
2429

Teacher Zhu: When I test uploading a file whose format does not meet the requirements, the page reports an error (500 error); what's going on?


**13
**13

reply all(3)
Summer

You probably haven’t reached the update method yet, come here

政治13

When uploading a file in the correct format, the prompt message is set in the controller: Upload successful! This is no problem;

But when uploading a file in the wrong format, the prompt message is Page Error 500? ??

The following is the code (same as the teacher’s):

public function update(){
//Get all request data including uploaded files:
$data= $this->request->param(true);
//For individual file operations, package it into a file object
$file=$this->request->file('image') ;
//File verification and upload:
$info=$file->validate(['ext'=>'jpg,png','size'=>3000000])->move (ROOT_PATH.'public/uploads/');
if(is_null($info)){
$this->error($file->getError());
}
//Perform update operation
$res=banner_model::update([
] 'image'=>$info->getSaveName(),
'link'=>$data['link' ],
'desc'=>$data['desc'],
],['id'=>$data['id']]);
//Check whether the update is successful :
if(is_null($res)){
$this->error('Update failed');
}
$this->success('Update successful');

}

Masters, please help me take a look;

无忌哥哥

It should be that the ajax code is written incorrectly, please check the code carefully. ,

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template