Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Force download #2995

Closed
CatAnonymous opened this issue May 14, 2020 · 3 comments
Closed

Bug: Force download #2995

CatAnonymous opened this issue May 14, 2020 · 3 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@CatAnonymous
Copy link

CatAnonymous commented May 14, 2020

PHP error: Error Call to a member function setFileName() on null

/*
var_dump(is_file($path)); // return true
var_dump(basename($path)); // return test.zip
*/
return $this->response->download($path)->setFileName(basename($path));

CI Version: 4.0.2
PHP Version: 7.4.3

@CatAnonymous CatAnonymous added the bug Verified issues on the current code behavior or pull requests that will fix them label May 14, 2020
@paulbalandan
Copy link
Member

Try setting the second argument of $this->response->download to a value of null.

@CatAnonymous
Copy link
Author

Try setting the second argument of $this->response->download to a value of null.

According to the documentation, the second argument is unnecessary. Is this counted as a bug?

@paulbalandan
Copy link
Member

From the docs:
If you set the second parameter to NULL and $filename is an existing, readable file path, then its content will be read instead.

Based on your code example, you really need to set the second argument to null.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

2 participants