vendredi 28 juin 2019

In laravel 5 problem with checking/reading uploaded file

In laravel 5.7 app uploading file under storage

   // $dest_image = "/page-contents/-page-content-1/1.png"
    Storage::disk('local')->put($dest_image, File::get($page_content_file_path));

file is uploaded as

myapp/storage/app/page-contents/-page-content-1/1.png

Reading file I want to check if file exists and read it with all its props( size, width, height, system full path)

//$file_full_path= ‘page-contents/-page-content-1/1.png’
$file_exists    = ( !empty($image) and Storage::disk('local')->exists( $file_full_path) );

I got false, but file really exists

1) I can check as :

$file_exists    = ( !empty($image) and Storage::disk('local')->exists('public/' . $file_full_path) );

if shows true if file exists, but I am not sure if it a valid way ?

2) Reading full fiel path

 $image_full_path = storage_path( $image_path);

I got string “myapp/storage/page-contents/-page-content-1/1.png”, but it is without “/app/” as it was stored

I have all storage options default.

Which is valid way ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire