2016-04-06 44 views
1

我用流明來獲得在瀏覽器圖像和演出,我在控制器代碼:圖片在瀏覽器中不顯示管腔阿比

use Illuminate\Support\Facades\File; 

    $photo = $this->uploadFile->get_by_photo($photo, ['filename']); 
    $path = storage_path('app') . '/' . $photo[0]['filename']; 
    $file = File::get($path); 
    $type = File::mimeType($path); 
    $response = response()->make($file, 200); 
    $response->header("Content-Type", $type); 
    return $response; 

但圖像在瀏覽器中不顯示,我只能在運行時一個黑暗的一頁該API

+0

請朋友們有所幫助 – amirali

回答

1

此代碼的工作:

$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;