Welcome Guest, Not a member yet? Register   Sign In
*Fix* Make upload field required or not required
#1

[eluser]Unknown[/eluser]
When you don't upload anything an error appeared, (error 4). But not always the upload field is required... So i make some changes to the upload class....

Check this out....

file: system\libraries\Upload.php

1) add this var to the CI_Upload Class (line 29)
Code:
var $required       = 1;

2) add this attribute to the initialization function (line 82)
Code:
'required'            => 1,

3) add these lines to the do_upload function (line 155)
Code:
if($this->required == -1 && $_FILES[$field]['tmp_name'] == '')
    return TRUE;




so when you try to upload something from your controller add this to your config
Code:
$config['required'] = '-1';


by Michalis Tzikas
Greece


psaxno.com - Create your own search engine




Theme © iAndrew 2016 - Forum software by © MyBB