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);