Welcome Guest, Not a member yet? Register   Sign In
Validation always return error
#3

(04-10-2021, 10:35 PM)iRedds Wrote: I will try to explain the reason.

You are using spoofing:
Code:
<input type="hidden" name="_method" value="put" />
This makes the framework assume that the request method is not POST, but PUT.

In the controller, when the validate() method is called, an instance of the Validation class is created and passed the request to it. And the class automatically determines the data for validation by the type of request.

Since the framework has defined the method as PUT, the Validation class tries to get data from the request body via php://input.

And this is where the fun begins.
When you specify the encryption method 'multipart/form-data' in the enctype attribute in the form tag, the request is encoded in a special way, and get it through the php://input impossible.

I have counted 3 ways to solve the problem so far.
1. Don't use encoding 'multipart/form-data'
2. Do not use spoofing.
3. Do not use controller validation method. In this case, you can write the implementation of this method yourself, and pass the data to the Validation::run() method.

https://github.com/codeigniter4/CodeIgni...ssues/4552

I'm interested in the first solution, 'cause for the other two I have no clue how to setup them. Could you please show me an example of file uploading without using `multipart/form-data`?

Thanks again
Reply


Messages In This Thread
Validation always return error - by sfarzoso - 04-10-2021, 12:22 PM
RE: Validation always return error - by iRedds - 04-10-2021, 10:35 PM
RE: Validation always return error - by sfarzoso - 04-11-2021, 02:41 AM
RE: Validation always return error - by iRedds - 04-11-2021, 05:57 AM
RE: Validation always return error - by sfarzoso - 04-11-2021, 07:59 AM
RE: Validation always return error - by InsiteFX - 04-11-2021, 11:22 AM
RE: Validation always return error - by iRedds - 04-11-2021, 06:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB