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; }
$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); } } } if ($list == 1) { $htmlstr = '<li class="itempic"><img class="fmpic" src="' . $php_url . pic_url($file_url) . '" height="80" alt=""><input type="hidden" name="' . $filepicname . '[]" value="' . $file_url . '"> <div class="editro"> <a href="javascript:void(0)" class="up_pic">上移</a> <a href="javascript:void(0)" class="botm_pic">下移</a> <a href="javascript:void(0)" class="del_pic">删除</a> </div></li>';