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

CodeIgniter\Files\File() and FileNotFoundException issue with creating new files #548

Closed
timothymarois opened this issue Jun 13, 2017 · 2 comments

Comments

@timothymarois
Copy link
Contributor

I'm adding this as an issue because you're unable to create a file using the file class. It automatically hits FileNotFoundException when the file does not exist, and preventing $file->openFile('w') from allowing it to create the file.

As for documentation: Getting a File instance

The file does not need to exist.

Technically it will need to exist, because without using a try/catch the application will crash. Forcing you to use the default fopen if you need to create the file on the fly.

@lonnieezell
Copy link
Member

Ah. Looks like docs may be off there, since you can bypass the exception by passing false as the second parameter in the constructor:

$file = new File($path, false);

I'm guessing I originally meant it to be default to false... and then forgot to change docs when it was changed. Most likely while I was working on the Image library.

see: https://github.com/bcit-ci/CodeIgniter4/blob/develop/system/Files/File.php#L61

@timothymarois
Copy link
Contributor Author

ah I see. cool. no worries then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants