![]() |
Image handling and 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: Image handling and upload (/showthread.php?tid=57537) |
Image handling and upload - El Forum - 03-21-2013 [eluser]ibnclaudius[/eluser] I have this form submit, everything works fine, I'm having problem handling the picture, for example, how can I check if the image is a square before uploading it? Code: $data['name'] = trim($this->input->post('name')); Image handling and upload - El Forum - 03-21-2013 [eluser]TheFuzzy0ne[/eluser] You can't check that the image is a square before uploading it without some kind of Flash or Java applet embedded on the page. Once the file is uploaded, you can either crop it to a square using the image library, or use getimagesize() to get the image dimensions and see if it's square. Another observation, it would be wiser to call $this->session->set_userdata() once. If you are storing your sessions in the database, or ever decide to, an update will be fired at the database once for each call to $this->session->set_userdata(). Code: $this->session->set_userdata(array( Image handling and upload - El Forum - 03-21-2013 [eluser]ibnclaudius[/eluser] [quote author="TheFuzzy0ne" date="1363894881"]You can't check that the image is a square before uploading it without some kind of Flash or Java applet embedded on the page. Once the file is uploaded, you can either crop it to a square using the image library, or use getimagesize() to get the image dimensions and see if it's square. Another observation, it would be wiser to call $this->session->set_userdata() once. If you are storing your sessions in the database, or ever decide to, an update will be fired at the database once for each call to $this->session->set_userdata(). Code: $this->session->set_userdata(array( Thanks! Another thing, is there any way I can check if there's a file to upload? Something like: Code: if (theres_file_to_upload) |