function test(&$id, &$img){ $photodata = file_get_contents($img); $url = UPLOAD_IMAGE_URL; // if ($compress == 'N') { // $url = UPLOAD_IMAGE_URL . '&compress=n'; // } $upload = http_parse_message(http_post_data($url, $photodata)); $result = (array) $upload; if (!empty($result) && $result['body']) { $newPicId = explode("=", $result['body']); if (!empty($newPicId[1]) && $newPicId[1] > 0) { $result[0] = true; $id = Lib_String::filterBlank(($newPicId[1])); } elseif (!empty($newPicId[1]) && $newPicId[1] <= 0) { $result[0] = false; $result[1] = "上传失败"; } else { $result[0] = false; $result[1] = "上传失败"; } } else { $result[0] = false; $result[1] = "上传失败"; } }
public static function filterBlank($str) { mb_regex_encoding('utf-8'); $str = mb_ereg_replace(' ', '', $str); return trim($str); }