[solved] CI4 request missing POST and FILES data |
I've been hitting my head against my keyboard all afternoon trying to figure this out.
I've got a page that has an image uploader. When I post from the page to a plain PHP page, the file uploads as expected. But when I post to my controller function, the POST and FILES data are empty. I think it might have something to do with where the IncomingRequest is being instantiated, but I can't figure it out. Essentially I have this route for do_upload, like: PHP Code: public function do_upload(){ Even though I seem to be posting to the page correctly, I get PHP Code: Array ( ) Array ( ) Array ( ) Meanwhile, $this->request has tons of info... but just nothing I can find about POST or FILES. Any ideas? Using CI 4.0.0 rc3 One thing I forgot to mention, I'm using some variable routing here, so I wonder if that is short-circuiting the POST. In my routes, I've got an entry like this: $routes->add('editor/do_upload/(:any)', 'Editor::do_upload'); The 3rd parameter is an ID that ties the upload back to a database record. Designer, developer and Diet Dr. Pepper addict. Messing up PHP since <?= $when['year';] ?>
Seems dumb to answer my own question, but I did finally figure this out. Apparently the wildcard routing starts a new HTTP request, so the POST and FILES info was getting lost.
When I changed my route to editor/do_upload instead of editor/do_upload/(:any), it started working. I just had to tweak it to pass my URL parameter as a hidden POST field instead. Designer, developer and Diet Dr. Pepper addict. Messing up PHP since <?= $when['year';] ?>
Hello ! On the contrary, it is a very good idea to post the solutions, when you have them. I do it too. This can always be useful to others ;-)
Another suggestion, you could add [Solved] in the subject of your thread too, so people know that help is not needed anymore :-) |
Welcome Guest, Not a member yet? Register Sign In |