Welcome Guest, Not a member yet? Register   Sign In
how to transfer large data across a redirect

Hey y'all,

currently, I am trying to submit a form with a user excel file and relay the error messages in that file using flashdata. The problem is that when the Error List becomes too large, i get a 302 Moved Temporarily Error. When adding this line in:

if( isset($query['errorList']) ) { $this->session->set_flashdata('errorList', $query['errorList']); }

(query is the return value of the model that is checking the excel file / inserting the excel file into the database)
(i'm actually not sure whether this line is causing the error or the redirect after is)

Moved Temporarily

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, ________________ and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Anyways, my question is where is the best place to store this data across a redirect if not flashdata.

How are you storing sessions? Cookie/db/etc...

i'm saving it across a cookie but I see what you mean as the user manual says cookies are no more than 4KBs (less with encryption enabled) Codeigniter Session Class

Would storing it in a DB be the fix?

Yes. If you are saving the excel file to session, I would also suggest saving it as a file and storing the path/filename in session instead of the actual file.

Why are you storing error messages in the flashdata? CI comes with form validation built in, check the manual.

What I'd do is do all your form validation using JS... once it passes that only then will the form submit to your php/ci controller. It's a bit more user friendly because no page reloads when validation fails, thus the user only need to "select file to upload" once (which can be a drag if it's deeply nested within the folder tree/structure).

Now your file only get's uploaded once from their machine to your local temp folder on your server once JS validation has passed.

I would still do php form validation, we all know how bad it is just to rely on JS validation!!!

The only reason the php validation should fail if the user is malicious and doing something naughty, or they are one of the 0.01% of users who have JS disabled. Either way, just reload the page/form if validation does fail server side.

Only once the form passes both JS and PHP validation do you need to worry about the file upload.

Sounds a bit like to me you're making a complex solution to a simple problem (which we all do from time to time!).

Theme © iAndrew 2016 - Forum software by © MyBB