2017-10-21 8 views
0

본 가이드를 따르고 있습니다. Google 드라이브에 이미지를 업로드 할 수는 있지만 파일 경로를 가져올 수 없습니다.api를 통해 Google 드라이브에 업로드 한 후 파일에 대한 링크를 얻는 방법은 무엇인가요?

https://gist.github.com/ivanvermeyen/cc7c59c185daad9d4e7cb8c661d7b89b

// Get img that was uploaded to my server 
$img = request()->file('img'); 

// Save that image to my google drive 
Storage::disk('google')->put('img.png', fopen($img, 'r+')); 

// ?? how do I get the path to the file so I can save it in my database? 

답변

0

당신은 laravel 문서에 그것을 봤어?

https://laravel.com/docs/5.5/filesystem#file-urls

코드의 경우이를 사용해야합니다

use Illuminate\Support\Facades\Storage; 

$url = Storage::disk('google')->url('img.png'); 

dd($url); 
+0

img.png 파일의 이름입니다. 그래서 그렇게하면 빈 파일이 저장됩니다. 파일은 $ img이고 im은 img.png로 저장합니다 – jeff923

+0

URL을 얻으려면 파일 이름을 사용해야합니다. 그게 뭐가 잘못 되었나요? 너 해봤 어? 어쩌면 마지막 줄 다음에'dd ($ url)'을 추가하십시오. – PKeidel