Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
CodeIgniter

File Upload in CodeIgniter

Upload files with CodeIgniter’s IncomingFile handling and move them to writable/uploads.

File Upload in CodeIgniter — a practical guide to CodeIgniter file upload with clear examples you can reuse in real projects.

CodeIgniter Tutorial Series (41/74). Prefer one article? Read the complete CodeIgniter tutorial.

Short description

Validate size/extension, then move the file to a safe directory outside or inside public as needed.

Upload handler

$file = $this->request->getFile('document');
if (! $file->isValid()) {
    return redirect()->back()->with('error', $file->getErrorString());
}
$name = $file->getRandomName();
$file->move(WRITEPATH . 'uploads', $name);

Leave a reply

Your email address will not be published. Required fields are marked *