Check to see if there is a file to upload - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Check to see if there is a file to upload (/showthread.php?tid=25258) |
Check to see if there is a file to upload - El Forum - 12-06-2009 [eluser]jake142[/eluser] Hi, Im new to codeigniter (and new to php). How can I check if there is a file to upload, befor I do the actual upload? The $this->input->post('userfile')!="" doesn't work. Code: if($this->input->post('userfile')!="") Any help is very appritiated. Thanks! Check to see if there is a file to upload - El Forum - 12-06-2009 [eluser]JoostV[/eluser] Code: if (isset($_FILES['userfile']['name']) && $_FILES['userfile']['name'] != "none") { Check to see if there is a file to upload - El Forum - 12-06-2009 [eluser]jake142[/eluser] Hi, It doesn't work for me. $_FILES['userfile']['name'] is always '0' no matter if I have uploaded a file or not. I use <?php echo form_open_multipart('ads/do_save');?> in my view to post the uploaded file. <input type="file" id="userfile" name="userfile" size="29" /> is the file upload element. Any ideas? Thanks. Check to see if there is a file to upload - El Forum - 12-06-2009 [eluser]umefarooq[/eluser] best way is to check is Code: if($_FILES['upload']['error'] == 0){ Check to see if there is a file to upload - El Forum - 12-06-2009 [eluser]jake142[/eluser] Hi, Thanks everyone. I need to check that the user really uploaded a file before I upload it. Using: $_FILES['userfile']['size']!='0' solved my problem. Thanks. |