Welcome Guest, Not a member yet? Register   Sign In
want to read the contents of files and need validation
#1

In my CodeIgniter project, I want to read the contents of files and need validation to confirm if a file is selected. I have written code in the controller using $this->form_validation->set_rules() function, but I am getting an error that says "The Project Estimation File field is required" even after selecting a file. What could be the issue?
Reply
Reply
#3

you are trying to validate a file upload field in your CodeIgniter project using the form validation library, but encountering an error message that the file field is required even after selecting a file.

There are several possible reasons why this error message is being displayed. Here are a few things you can check:

Make sure that the name attribute of your file input field matches the name specified in your validation rule. For example, if you have set a validation rule for a file input field named "project_estimation_file", then the name attribute in your HTML should also be "project_estimation_file".

Verify that the enctype attribute in your form tag is set to "multipart/form-data". This is necessary for file uploads to work properly.

Check if there are any file upload restrictions set in your php.ini file. For example, if the maximum file size is set to a lower value than the size of the file you are trying to upload, this could cause the validation to fail.

Verify that the file input field is actually being submitted as part of the form data. You can check this by inspecting the network tab in your browser's developer tools to see if the file is being sent as part of the form data.

If none of the above suggestions work, you could try debugging your code by printing out the values of the $_FILES array and checking if the file input field is being populated with the uploaded file.

I hope this helps you to identify the issue and resolve the error message you are encountering. Let me know if you have any further questions or concerns.
Reply
#4

Show your code for the form and validation.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB