2017-02-26 23 views
3

Interventionを使用してイメージのサイズを変更し、定義したディスクに保存しようとしていますが、動作させることができません。 public_folderを使用すると、/ publicと呼ばれるアプリケーションのルートにあるフォルダに保存されます。Laravel Intervention特定のディスクに画像を保存する

私は

'disks' => [ 

    'local' => [ 
     'driver' => 'local', 
     'root' => storage_path('app'), 
    ], 

    'public' => [ 
     'driver' => 'local', 
     'root' => storage_path('app/public'), 
     'visibility' => 'public', 
    ], 

    'images' => [ 
     'driver' => 'local', 
     'root' => storage_path('app/public/images'), 
     'visibility' => 'public', 
    ], 

新しいディスクを作成していると私は、DBへのその後のファイルパス、そのディスクへのアップロードされたファイルを保存し、ユーザからの入力を受け付ける必要があります。

私は画像のディスクを変更した場合、ファイルは、

/path/to/laravel/storage/app/public/images/ 

その後で終わる必要があります

$fieldValue = $fieldFile->store($fieldName, 'images'); 

からどうするかのようなもので終わるしたい

$fieldFile = $request->file($fieldName); 
$imageName = time(); 
Image::make($fieldFile)->crop(350, 350)->save(public_path() . '/' . $imageName . '.' . $fieldFile->getClientOriginalExtension()); 
$object->$fieldName = public_path() . '/' . $imageName . '.' . $fieldFile->getClientOriginalExtension(); 

s3または他のどこかで、私はこのコードが機能し続けることを望みます。

答えて

0
$fieldFile = $request->file($fieldName); 
//$imageName = time(); 

$mime= $fieldFile->getClientOriginalExtension(); 
$imageName = time().".".$mime; 
$image = Image::make($fieldFile)->crop(350, 350) 

$location = Storage::disk('images')->put($imageName, $image); 
//images can be substituted for any disk local or s3 etc. 
+0

私のためには機能しません。 – Turtle

関連する問題