function dzz_backimg_save($FILE, $dir = 'appimg') { global $_G; $allowpictype = array('jpg', 'jpeg', 'gif', 'png'); $upload = new dzz_upload(); $upload->init($FILE, $dir); if ($upload->error()) { return $upload->errormessage(); } if (!$upload->attach['isimage']) { return '只能上传图片文件'; } $upload->save(); if ($upload->error()) { return '保存失败'; } $setarr = array('filepath' => $dir . '/' . $upload->attach['attachment'], 'thumb' => 0); //生成缩略图 require_once libfile('class/image'); $image = new image(); if ($thumb = $image->Thumb($_G['setting']['attachurl'] . $setarr['filepath'], '', 101, 101, 1)) { $setarr['thumb'] = $thumb; } return $setarr; }
function save_to_local($source, $target) { if (!dzz_upload::is_upload_file($source)) { $succeed = false; } elseif (@copy($source, $target)) { $succeed = true; } elseif (function_exists('move_uploaded_file') && @move_uploaded_file($source, $target)) { $succeed = true; } elseif (@is_readable($source) && @($fp_s = fopen($source, 'rb')) && @($fp_t = fopen($target, 'wb'))) { while (!feof($fp_s)) { $s = @fread($fp_s, 1024 * 512); @fwrite($fp_t, $s); } fclose($fp_s); fclose($fp_t); $succeed = true; } if ($succeed) { $this->errorcode = 0; @chmod($target, 0644); @unlink($source); } else { $this->errorcode = 0; } return $succeed; }