记住用户名密码
//图片上传 function uploadImage($dirName) { $file_temp = $_FILES['file']['tmp_name']; $file_name = mt_rand(); $file_dir = $dirName; $file_type = $_FILES['file']['type']; switch($file_type){ case 'image/jpeg': $file_ext = '.jpg';break; case 'image/png': $file_ext = '.png';break; case 'image/gif': $file_ext = '.gif';break; case 'video/mp4': $file_ext = '.mp4';break; default: throw new Exception('文件格式不适合'); } $file_dir = './images'.'/'.$file_dir; if (!file_exists($file_dir)){ mkdir($file_dir,777); } $file_path = $file_dir.'/'.$file_name.$file_ext; if(move_uploaded_file($file_temp,$file_path)){ // $upload_file['path'] = ltrim($file_path,'.'); $upload_file = ltrim($file_path,'.'); apiJson(200,'上传成功!', $upload_file); }else{ apiJson(500,'数据异常!'); } } //输出json返回值 function apiJson($code='', $message='',$reData='') { $value = array( 'code' => $code, 'message' => $message, 'result' => $reData ); exit(json_encode($value)); }
目前有 0 条留言 其中:访客:0 条, 博主:0 条