Ejemplo n.º 1
0
function GrabImage($url, $dir = 'updatefile/', $filename = "")
{
    global $sltarray;
    if ($url == "") {
        return false;
    }
    if ($filename == "") {
        $ext = strrchr($url, ".");
        if ($ext != ".gif" && $ext != ".jpg" && $ext != ".png") {
            return false;
        }
        $filename = date("YmdHis") . $ext;
    }
    ob_start();
    readfile($url);
    $img = ob_get_contents();
    ob_end_clean();
    $size = strlen($img);
    $file_path = KQ_PATH . $dir . SUOLUTDIR . "/" . $filename;
    $fp2 = @fopen($file_path, "a");
    fwrite($fp2, $img);
    fclose($fp2);
    $thumbs = new ThumbnailPic($file_path);
    foreach ($sltarray as $key => $sltvalue) {
        $thumbs->CreateThumbsize($sltvalue['w'], $sltvalue['h']);
    }
    return $filename;
}
Ejemplo n.º 2
0
     alert("上传文件失败。");
 }
 @chmod($file_path, 0644);
 $file_url = $new_file_name;
 $data2['kq_url'] = $file_url;
 $data2['kq_type'] = 1;
 $data2['kq_aburl'] = $file_path;
 $data2['kq_ctime'] = $ymd;
 $data2['kq_uuid'] = md5(uniqid(rand(), true) . rand(1, time()));
 $data2['kq_title'] = $file_name;
 if ($conn->post_insert("" . DB_EXT . "file", $data2)) {
 } else {
     exit("入库失败");
 }
 if (SUOLUETU) {
     $thumbs = new ThumbnailPic($file_path);
     //比例问题
     if ($bili) {
         foreach ($sltarray as $key => $sltvalue) {
             $thumbs->CreateThumbsize($sltvalue['w'], $sltvalue['h'], '', 1);
         }
         if ($upsize_w != '') {
             $thumbs->CreateThumbsize($upsize_w, $upsize_h, 1, 1);
         }
     } else {
         foreach ($sltarray as $key => $sltvalue) {
             $thumbs->CreateThumbsize($sltvalue['w'], $sltvalue['h']);
         }
         if ($upsize_w != '') {
             $thumbs->CreateThumbsize($upsize_w, $upsize_h, 1);
         }