Segments not working with file upload |
[eluser]marss[/eluser]
Hi, I'm trying to send some arguments when making a file upload, my uploadscript is a copy of the example over at http://ellislab.com/codeigniter/user-gui...ading.html So I added two arguments: Code: <?php echo form_open_multipart('upload/do_upload/9/8');?> But these two never shows up in my controller - they are output in the HTML before submitting form though. Code: $this->uri->segment(3) Code: $_SERVER['REQUEST_URI'] Any ideas on why I don't recieve my /9/8? Thankfull for any input!
[eluser]InsiteFX[/eluser]
Thats the controller and function that it will post and I know you do not have function 8 or 9 in your controller. Maybe if you explain what you are trying to do we can help you.
[eluser]marss[/eluser]
[quote author="InsiteFX" date="1338311068"]Thats the controller and function that it will post and I know you do not have function 8 or 9 in your controller. Maybe if you explain what you are trying to do we can help you. [/quote] I wish to tag my uploads with a number. In this case the uploaded file would be tagged in the database with typeA = 8, typeB = 9. As I cannot add any extra field in the upload form since it contains a input type="file" I figured the best approach would be if I could just add my arguments in the <form action="">. Thanks for your reply.
[eluser]marss[/eluser]
[quote author="CroNiX" date="1338330045"]just send them as hidden form fields[/quote] Unfortunately that doesn't work when having a <input type="file"> from what I understood (?). Because in the controller I can only access $_FILES and $_POST is empty. For now I will have to return the uploadId on upload success and update my fields in the database with ajax I guess.
[eluser]LuckyFella73[/eluser]
Quote:Unfortunately that doesn’t work when having a <input type=“file”> from what I understood (?). That is not right. You can have all types of input fields in your form. Having a form element type:file does not restrict you in any way to use other form fields! So do it like Cronix said and use hidden input fields!
[eluser]CroNiX[/eluser]
You should be able to send any form element in a form. The only difference is how you access them on the server end. Files will always be in $_FILES and all other post data will be in $_GET or $_POST, depending on how you sent your form. |
Welcome Guest, Not a member yet? Register Sign In |