1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
public function uploadAvatar($photo = array()) { if (! empty ( $photo ['name'] )) { $upload_dir = BASE_PATH . "photos/profiles"; $md_dir = md5 ( $this->user_info ['email'] ); $pathname = $upload_dir . "/" . $md_dir; if (! file_exists ( $pathname )) { mkdir ( $pathname ); } $upload_photo = new upload ( $photo ); if ($upload_photo->uploaded) { $upload_photo->file_new_name_body = 'avatar2'; $upload_photo->image_convert = "jpg"; $upload_photo->image_min_width = 300; $upload_photo->image_min_height = 300; $upload_photo->file_auto_rename = false; $upload_photo->file_overwrite = true; $upload_photo->file_max_size = "300K"; $upload_photo->allowed = "image/*"; $upload_photo->Process ( $pathname . "/" ); if ($upload_photo->processed) { $photo = $upload_file->file_dst_name_body . "." . $upload_file->file_dst_name_ext; $return ['src'] = $photo; return $return; } else { $return ['err'] = 1; $return ['msg'] = $upload_photo->error; return $return; } } }else{ $return ['err'] = 1; $return ['msg'] = "Please select an image"; return $return; } } |