uploadFile($request->file('file')); if($status){ return $this->json_return(200,'上传成功',['url' => $data]); }else{ return $this->json_return(201,$data); } } //获取文件的位置预览(临时文件) public function getFile($file_name){ $file_name = str_replace(FileUploadService::string2,'',$file_name); $timestamp = substr($file_name, 0, 8); // 截取前八位数字 $date = \DateTime::createFromFormat('Ymd', $timestamp); $date = $date->format('Y-m-d'); $path = storage_path() . "/app/public/" . FileUploadService::tmp_dir . '/' . $date. '/' . $file_name; return response()->file($path); } //获取文件的位置 public function getFileLocal($file_name){ $path = storage_path() . "/app/public/upload_files/".$file_name; if(file_exists($path)) return response()->file($path); return ""; } }