![]() |
file upload fails but POST data looks fine (SOLVED - bug?) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: file upload fails but POST data looks fine (SOLVED - bug?) (/showthread.php?tid=36588) |
file upload fails but POST data looks fine (SOLVED - bug?) - El Forum - 12-07-2010 [eluser]munkeh[/eluser] I'm trying to upload a file and while the form seems to be working the upload helper gives me an error: You did not select a file to upload. The POST data is fine: $_POST['upload_file'] test.jpg $_POST['file_notes'] test permissions on the /var/www/website/htdocs/system/uploads directory are fine. PHP config as follows: file_uploads on max_file_uploads 20 upload_max_filesize 2M What am I doing wrong? My view: Code: <?php echo form_fieldset('upload'); ?> My Controller: Code: function upload_file() { file upload fails but POST data looks fine (SOLVED - bug?) - El Forum - 12-08-2010 [eluser]munkeh[/eluser] Solved the problem but possibly found a bug/feature? Or maybe I was just doing things wrong all along. I have been creating forms like this throughout my applications: Code: <?php echo form_open('add_claim/upload_file', 'name="upload_form"'); ?> Code: <form action="website/add_claim/upload_file" name="upload_form" method="post"> According to the docs I'm supposed to be passing the attributes as an array but juat adding them to the form_open function seemed to be working just fine so I kept on doing it. Truth be told I only really glanced at the docs for the form helper, so my bad there. Anyway, turns out if you do the same thing with a multipart form it doesn't work: Code: <?php echo form_open_multipart('add_claim/upload_file', 'name="upload_form"');?> Code: <form action="website/add_claim/upload_file" mame="upload_form" method="post"> note: mame="upload_form" instead of name="upload_form". This, I guess, was causing the do_upload() function to fail. Anyway, figured I'd at least update the thread in case anyone else was stumped by the same thing. |