2016-04-06 5 views
1

ich Lumen verwenden, um Bilder und zeigt in Browser zu bekommen, mein Code in Controller ist:Bild nicht mit Lumen Api in Browser anzeigen

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; 

Aber Bild zeigt nicht in Browser, ich habe nur eine dunkele Seite bei der Ausführung dass api

+0

bitte helfen Freunde – amirali

Antwort

1

dieser Code funktioniert:

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