2017-06-15 80 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