CodeIgniter Forums
How to check if file upload form is set - 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: How to check if file upload form is set (/showthread.php?tid=8112)



How to check if file upload form is set - El Forum - 05-06-2008

[eluser]Unknown[/eluser]
hello, I would like to ask you, how can I check if in file upload form is set any path to file.

I would take some condition depending on file upload form state but BEFORE! I use $this->upload->do_upload()


How to check if file upload form is set - El Forum - 05-06-2008

[eluser]Mark van der Walle[/eluser]
Note this assumes: <input type="file" name="myfile" />
Code:
if (isset($_FILES['myfile'])) {
    // do your thing here
}
Note that this does not check for valid upload etc.


How to check if file upload form is set - El Forum - 05-06-2008

[eluser]xwero[/eluser]
Code:
if ($_FILES['myfile']['error'] != 4) {
    // do your thing here
}
If you want to check if a file is selected.


How to check if file upload form is set - El Forum - 05-06-2008

[eluser]Unknown[/eluser]
thx! works great!