dimanche 5 juin 2016

Incorrect image path for storage folder : Laravel 5.2.31

I have following image tag in blade.

{!! Form::image('/MySplash/1/file.png', $alt="Photo", null) !!}

Below is my code in Route file..

Route::get('MySplash/{IconID}/{UniqueFileName}', function ($IconID, $filename)
{
    $path = storage_path() . '/SplashScreenIcons/' . $IconID . '/' . $filename;

    if(!File::exists($path)) {
        abort(404);
    }

    $file = File::get($path);
    $type = File::mimeType($path);

    $response = Response::make($file, 200);
    $response->header("Content-Type", $type);

    return $response;;
});

Finally I get the image url like below.

http://localhost/SportsApp/public/MySplash/1/file.png

What's the problem

  1. It does not go into route.
  2. Url is showing public. whereas the image folder is in storage directory.

Am I missing anything?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire