2017-06-15 79 views
-2

我试图作为一个正常的获取数据,但在图像领域的JSON响应显示错误。下面的代码是正确的?下面的代码如何从流明API中的数据库中获取图像?

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); 
    } 
+0

问题寻求帮助调试(“为什么不是这个代码的工作?”)必须包括所期望的行为,一个具体问题或错误,在问题本身中重现它所需的最短代码。没有明确问题陈述的问题对其他读者无益。请参阅:如何创建[mcve]。使用“编辑”链接来改善你的*问题* - 不要通过评论添加更多信息。谢谢! – GhostCat

回答

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; 
+1

仅提供代码解答,不妨考虑添加一些解释。请:了解如何正确格式化您的内容。 – GhostCat

+0

好的..我已经在我的代码 – Krunal

+0

,但我是一个新的堆栈和我的帐户被禁止问问题,所以我写了一个答案@ GhostCat – Krunal