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

Added ability to handle file uploads in a simple way #602

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

n0nag0n
Copy link
Collaborator

@n0nag0n n0nag0n commented Aug 21, 2024

You can now use Flight::request()->getUploadedFiles(); which will return an array of your $_FILES array to more easily handle file uploads.

Example:

// $_FILES array
$_FILES['file'] = [
    'name' => 'file.txt',
    'type' => 'text/plain',
    'size' => 123,
    'tmp_name' => '/tmp/php123',
    'error' => 0
];

$file = Flight::request()->getUploadedFiles()['file'];

$file->moveTo('/move/to/this/path.txt');

@n0nag0n n0nag0n merged commit 63fbf9b into master Aug 22, 2024
@n0nag0n n0nag0n deleted the file-upload-handler branch August 22, 2024 17:05
@n0nag0n
Copy link
Collaborator Author

n0nag0n commented Aug 22, 2024

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

Successfully merging this pull request may close these issues.

1 participant