Tag:com inpu width xxxxx Get turn host done enter
public function Avatarupload () {$file = Request ()->file (' file '); $filePath = ' Avatar '; $width = 200; $height = 200; if ($file) {$filePaths = Root_path. ' Public '. Ds. ' Uploads '. DS. $filePath; if (!file_exists ($filePaths)) {mkdir ($filePaths, 0777,true); } $info = $file->move ($filePaths); if ($info) {$imgpath = $filePaths. ‘/‘ . $info->getsavename (); $image = \think\image::open ($imgpath); $image->thumb ($width, $height)->save ($imgpath); $imgpath = '/uploads/'. $filePath. ' /'. $info->getsavename (); $data = [' domain ' = ' $_server[' http_host '], ' filepath ' and ' = $imgpath,]; return [' Code ' = 0, ' data ' + $data, ' msg ' = ' upload succeeded ']; }else{//upload failed to get error message return [' Code ' = 1, ' data ' = ' ', ' msg ' = ' upload failed ']; } }}
<! DOCTYPE html>
THINKPHP5 Image Upload Interface