Welcome Guest, Not a member yet? Register   Sign In
Use one time library instead of two time
#1

[eluser]kolxoznik1[/eluser]
As I understand correctly from this code I ask one time "image_upload" if have error and two time when everything is ok! so first time I check for error and the second chtck / get data to variable. Is there a chance to check for error and if no get data, not to ask two time?

Code:
if (!$this->image_upload_lib->image_upload($config)) {
                    $error_status = "error";
                    $error_msg = $this->image_upload_lib->get_error_message();
} else {          
      $image_name = $this->image_upload_lib->image_upload($config);
}

Just want to improve my code and get more knowledge.

Thank you !
#2

[eluser]Aken[/eluser]
Since "image_upload_lib" is not a standard CI library, can't really say for sure what's correct for it specifically. But that's pretty redundant code - you should perform the upload once, then check if it was successful. The CI File Upload library has an example of how it handles uploads.




Theme © iAndrew 2016 - Forum software by © MyBB