2017-11-24 4 views
0

내 laravel 프로젝트에서 https://github.com/kunalvarma05/dropbox-php-sdk이 라이브러리를 사용하고 있습니다.이 코드에서이 "example.txt"파일을 내 프로젝트 디렉토리에 다운로드했습니다. 하지만이 "example.txt"파일을 브라우저에서 다운로드하여 브라우저 다운로드 폴더에 저장하려고합니다.어떻게 Dropbox API에서 로컬로 파일을 다운로드 할 수 있습니까

$file = $dropbox->download("/example.txt"); 
    $contents = $file->getContents(); 
    $metadata = $file->getMetadata(); 
    file_put_contents(__DIR__ . "/example.txt", $contents); 

답변

0

Google과 함께 사용하면 거의 없습니다.

$file = $dropbox->download("/my-logo.png"); 
//File Contents 
$contents = $file->getContents(); 
//Save file contents to disk 
file_put_contents(__DIR__ . "/logo.png", $contents); 
//Downloaded File Metadata 
$metadata = $file->getMetadata(); 
//Name 
$metadata->getName(); 

예와 github에 링크 : https://github.com/kunalvarma05/dropbox-php-sdk/wiki/Upload-and-Download-Files

+0

죄송합니다, 내가 유를 이해할 수 없었다 같아요. 내 코드는 이미 프로젝트 디렉토리에서 작업 중입니다. 그 파일을 내 프로젝트 경로에 다운로드하십시오. 그러나 해당 파일을 브라우저의 로컬 다운로드 디렉토리에 저장하려고합니다. 희망은 u를 이해 –

+0

죄송합니다, 내 실패 .. 그럼 당신이 필요합니다 : '$ 파일 = __DIR__. "/example.txt"; $ size = filesize ($ file); header ('Content-type :'.mime_content_type ($ file)); header ("Content-length : $ size"); header ('Content-Disposition : attachment; filename = "'. basename ($ file). '"'); readfile ($ file);' – Aurimas

관련 문제