💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
~~~ if ($request->hasFile('file') and $request->file('file')->isValid()) { $result = array(); //文件大小判断 $max_size = 1024 * 1024 * 50; $size = $request->file('file')->getClientSize(); if ($size > $max_size) { $result['status'] = 0; $result['info'] = '文件大小不能超过50M'; return $result; } //上传文件夹,如果不存在,建立文件夹 $date = date("Y_m"); $path = getcwd() . '/uploads' ; if (!is_dir($path)) { mkdir($path, 0777, true); } $file_oldname=$request->file('file')->getClientOriginalName(); //获得原文件名 $ext = $request->file('file')->getClientOriginalExtension(); $filename = date('YmdHis') . '_'.$hwid.'_' . uniqid() . '.' .'log'; // $request->file('file')->move($path, iconv('utf-8', 'gbk', $filename)); //windows $request->file('file')->move($path, $filename); //linux $filePath=$path.'/'.$filename; $file_md5= md5File('/uploads/'.$filename); $file_data=['hwid'=>$hwid,'file_name'=>$filename,'file_path'=>'uploads','md5'=>$file_md5]; Logfile::create($file_data); $data =['result'=>'success','msg'=>'file upload success!','files'=>['hwid'=>$hwid,'name'=>$filename,'path'=>public_path().'/uploads/'.$filename,'fileSize'=>$size,'md5'=>$file_md5]]; return response()->json($data); } ~~~