Validation for file upload extension error using ext_in[] in codeigniter 4

Viewed 892

I'm using flutter to upload files to a Php codeigniter 4 server. My problem is when I add validation for the uploaded file type. It always return file does not have a valid file extension.

Upload.php

$rules = [
 'file' => 'uploaded[file]|max_size[file, 4096]|ext_in[file,jpg,jpeg,png,doc,docx,pdf]'
];

Here is the debug of $_FILES that I recieved.

{"file":{"name":"file_test.jpg","type":"application\/octet-stream","tmp_name":"C:\\xampp\\tmp\\php623C.tmp","error":0,"size":169233}}
1 Answers

You missed the form field

enctype="multipart/form-data"
Related