如何在流明api中从数据库中获取图像?

时间:2017-06-15 07:07:32

标签: lumen

我已尝试正常获取数据,但在json响应中显示图像字段中的错误。下面的代码是对的??

public function up()
    {
        Schema::create('admin', function (Blueprint $table) {
            $table->increments('id');
            $table->string('username');
            $table->string('password');
            $table->string('profile_pic');  
});

并获取代码以下的数据

public function log() {

        $users = AdminLogin::all();

        return response()->json($users);
    }

1 个答案:

答案 0 :(得分:0)

$photo = $this->uploadFile->get_by_photo($photo, ['filename']); 
$path = storage_path('app') . '/' . $photo[0]['filename']; 
$type = File::mimeType($path); 
$headers = array('Content-Type' => $type); 
$response = response()->download($path, $photo, $headers); ob_end_clean(); 
return $response;