CodeIgniter Optional Upload / Optional Email Attachment - Solved |
[eluser]RaGe10940[/eluser]
Very true... thank you Code: array(1) { ["files"]=> array(5) { ["name"]=> array(1) { [0]=> string(0) "" } ["type"]=> array(1) { [0]=> string(0) "" } ["tmp_name"]=> array(1) { [0]=> string(0) "" } ["error"]=> array(1) { [0]=> int(4) } ["size"]=> array(1) { [0]=> int(0) } } } I will look into is_uploaded_file(). thank you.
[eluser]RaGe10940[/eluser]
Using if(is_upload_file($_FILES['files']['tmp_name']) [/code] as shown in the php.net example link : http://www.php.net/manual/en/function.is...d-file.php returns : Message: is_upload_file() expects parameter 1 to be string array given... I tried this both with : Code: <input type="file" name="files[]" multiple /> and Code: <input type="file" name="files" multiple /> both with the same message...
[eluser]RaGe10940[/eluser]
I feel really cheap doing it this way but it works dam well : Code: if (($_FILES['files']['error'][0] != 4) && ($_FILES['files']['name'][0] !="")) { my logic : the first array item in [error] WILL ALWAYS be [0] so that covers if your only uploading one file or multiple files (since the following arrays for [error] will be 1 2 3 4 5 6 and so on) this also allows me to check if the first file array [0] is now != 4 and and if [0] is = "" (not existent) I could probably do a foreach for the third [] but this is working for no, single and multiple uploading for my email system. Thank you to both Fuzzy and Aken
[eluser]TheFuzzy0ne[/eluser]
You're right. I completely smegged up my logic there. Sorry. |
Welcome Guest, Not a member yet? Register Sign In |