0

I may be missing something exceptionally obvious here, but I'm using yii2-flysystem along with Dropbox to read and write files.

I can upload and write them to Dropbox with no problem but then, when reading like this:

$file = Yii::$app->dropboxFs->read($fn);

..all that gives me is a string (/tmp/phpQkg8mJ).

How do I actually force the download of the file that I'm reading? I'm not sure what that temporary file location actually relates to.

Gary Fox
  • 31
  • 2

1 Answers1

0

Try function readfile(). According to example, your code should be looks something like this:

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename="'.basename($file).'"');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    readfile($file);
    exit;
}
Andrii Filenko
  • 954
  • 7
  • 17
  • Unfortunately file_exists($file) returns false...if I do readfile($file) I get 'No such file or directory' – Gary Fox Jul 21 '16 at 12:26