本文整理汇总了PHP中ImageResize函数的典型用法代码示例。如果您正苦于以下问题:PHP ImageResize函数的具体用法?PHP ImageResize怎么用?PHP ImageResize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ImageResize函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: time
$imgurl = '';
}
if (empty($dd)) {
$dd = '';
}
if ($dopost == 'upload') {
$ntime = time();
$cfg_ml->CheckUserSpace();
$filename = MemberUploads('imgfile', '', $cfg_ml->M_ID, 'image', '', -1, -1, true);
$dfilename = ereg_replace("(.*)/", "", $filename);
SaveUploadInfo("对话框上传 {$dfilename} ", $filename, 1);
if ($dd == "yes") {
$litfilename = str_replace(".", "-lit.", $filename);
copy($cfg_basedir . '/' . $filename, $cfg_basedir . '/' . $litfilename);
SaveUploadInfo("对话框上传 {$dfilename} 的小图", $litfilename, 1);
ImageResize($cfg_basedir . '/' . $litfilename, $w, $h);
$urlValue = $filename;
$imgsrcValue = $litfilename;
$info = '';
$sizes = getimagesize($cfg_basedir . '/' . $litfilename, $info);
$imgwidthValue = $sizes[0];
$imgheightValue = $sizes[1];
$imgsize = filesize($cfg_basedir . '/' . $litfilename);
} else {
$imgsrcValue = $filename;
$urlValue = $filename;
$info = '';
$sizes = getimagesize($cfg_basedir . '/' . $filename, $info);
$imgwidthValue = $sizes[0];
$imgheightValue = $sizes[1];
$imgsize = filesize($cfg_basedir . '/' . $filename);
示例2: DownMedia
/**
* 下载特定资源,并保存为指定文件
*
* @access public
* @param string $dourl 操作地址
* @param string $mtype 附件类型
* @param string $islitpic 是否缩略图
* @return string
*/
function DownMedia($dourl, $mtype = 'img', $islitpic = FALSE)
{
global $notckpic;
if (empty($notckpic)) {
$notckpic = 0;
}
//检测是否已经下载此文件
$wi = FALSE;
$tofile = $filename = '';
if ($notckpic == 0) {
$row = $this->dsql->GetOne("SELECT hash,tofile FROM `#@__co_mediaurls` WHERE nid='{$this->noteId}' AND hash='" . md5($dourl) . "' ");
if (isset($row['tofile'])) {
$tofile = $filename = $row['tofile'];
}
}
//如果不存在,下载文件
if ($tofile == '' || !file_exists($GLOBALS['cfg_basedir'] . $filename)) {
$filename = $this->GetRndName($dourl, $mtype);
if (!preg_match("#^\\/#", $filename)) {
$filename = "/" . $filename;
}
//防盗链模式
if ($this->noteInfos['isref'] == 'yes' && $this->noteInfos['refurl'] != '') {
if ($this->noteInfos['exptime'] == '') {
$this->noteInfos['exptime'] = 10;
}
DownImageKeep($dourl, $this->noteInfos['refurl'], $GLOBALS['cfg_basedir'] . $filename, '', 0, $this->Item['exptime']);
} else {
$this->cHttpDown->OpenUrl($dourl);
$this->cHttpDown->SaveToBin($GLOBALS['cfg_basedir'] . $filename);
$this->cHttpDown->Close();
}
//下载文件成功,保存记录
if (file_exists($GLOBALS['cfg_basedir'] . $filename)) {
if ($tofile == '') {
$query = "INSERT INTO `#@__co_mediaurls`(nid,hash,tofile) VALUES ('" . $this->noteId . "', '" . md5($dourl) . "', '" . addslashes($filename) . "');";
} else {
$query = "UPDATE `#@__co_mediaurls` SET tofile='" . addslashes($filename) . "' WHERE hash='" . md5($dourl) . "' ";
}
$this->dsql->ExecuteNoneQuery($query);
}
}
//如果下载图片失败或图片不存在,返回网址
if (!file_exists($GLOBALS['cfg_basedir'] . $filename)) {
return $dourl;
}
//生成缩略图
if ($mtype == 'img' && !$islitpic && $this->breImage == '') {
$this->breImage = $filename;
if (!preg_match("#^http:\\/\\/#", $this->breImage) && file_exists($GLOBALS['cfg_basedir'] . $filename)) {
$filenames = explode('/', $filename);
$filenamed = $filenames[count($filenames) - 1];
$nfilename = str_replace('.', '_lit.', $filenamed);
$nfilename = str_replace($filenamed, $nfilename, $filename);
if (@copy($GLOBALS['cfg_basedir'] . $filename, $GLOBALS['cfg_basedir'] . $nfilename)) {
ImageResize($GLOBALS['cfg_basedir'] . $nfilename, $GLOBALS['cfg_ddimg_width'], $GLOBALS['cfg_ddimg_height']);
$this->breImage = $nfilename;
}
}
}
if ($mtype == 'img' && !$islitpic) {
@WaterImg($GLOBALS['cfg_basedir'] . $filename, 'collect');
}
return $filename;
}
示例3: ImageUpload
?>
<script>window.alert("Upload Gagal, Pastikan File yang di Upload bertipe *.JPG, *.GIF, *.PNG");
window.location=("../../media.php?module=<?php
echo $module . '&act=edit&id=' . $_POST['id'];
?>
")</script>;
<?php
die;
}
//proses upload gambar sebenarnya
ImageUpload($fupload_name = $nama_file_unik, $to_dir = '../../../joimg/galeri/');
//proses resize image
$from_dir = "../../../joimg/galeri/";
//mencari file pada direktori
$to_dir = "../../../joimg/galeri/small/";
//letak file setelah proses resize pada direktori
$resize = 220;
//akan diperkecil sebesar ukuran file
ImageResize($nama_file_unik, $from_dir, $to_dir, $resize);
//proses resize
mysql_query("INSERT INTO galeri\n\t \t\t\t\t\t\t\t(\n\t \t\t\t\t\t\t\tid_album,\n\t\t\t\t\t\t\t\tnama,\n\t\t\t\t\t\t\t\tseo,\n\t\t\t\t\t\t\t\tgambar\n\t\t\t\t\t\t\t\t) \n\t\t\t\t\t\tVALUES \n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t'{$_POST['album']}',\n\t \t\t\t\t'{$_POST['nama']}',\n\t \t\t\t\t'{$judul_seo}',\n\t\t\t\t\t\t\t\t'{$nama_file_unik}'\n\t\t\t\t\t\t\t\t)\n\t \t\t\t\t");
} else {
mysql_query("INSERT INTO galeri\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\tid_album,\n\t\t\t\t\t\t\t\tnama,\n\t\t\t\t\t\t\t\tseo\n\t\t\t\t\t\t\t\t) \n\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t'{$_POST['album']}',\n\t \t\t\t\t'{$_POST['nama']}',\n\t \t\t\t\t'{$judul_seo}'\n\t \t\t\t\t)\n\t\t\t\t\t");
}
echo "<script>alert('Sukses! Data Telah Berhasil Disimpan.'); window.location = '../../media.php?module={$module}';</script>";
//header('location:../../media.php?module='.$module);
} else {
echo "<script>alert('Maaf! Data Gagal Disimpan, Silahkan coba lagi.'); window.location = '../../media.php?module={$module}';</script>";
}
}
}
示例4: ShowMsg
$dbbigfile = $filename . "." . $fs[count($fs) - 1];
$dblitfile = $filename . "_lit." . $fs[count($fs) - 1];
$fullfilename = $cfg_basedir . $bfilename;
$full_litfilename = $cfg_basedir . $litfilename;
if (file_exists($fullfilename)) {
ShowMsg("本目录已经存在同名的文件,请更改!", "-1");
exit;
}
@move_uploaded_file($imgfile, $fullfilename);
if ($dd == 'yes') {
copy($fullfilename, $full_litfilename);
if (in_array($imgfile_type, $cfg_photo_typenames)) {
if ($GLOBALS['cfg_ddimg_full'] == 'Y') {
@ImageResizeNew($full_litfilename, $w, $h);
} else {
@ImageResize($full_litfilename, $w, $h);
}
}
$urlValue = $bfilename;
$imgsrcValue = $litfilename;
$info = '';
$sizes = getimagesize($full_litfilename, $info);
$imgwidthValue = $sizes[0];
$imgheightValue = $sizes[1];
$imgsize = filesize($full_litfilename);
$inquery = "INSERT INTO `#@__uploads`(title,url,mediatype,width,height,playtime,filesize,uptime,mid)\r\n VALUES ('小图{$dblitfile}','{$imgsrcValue}','1','{$imgwidthValue}','{$imgheightValue}','0','{$imgsize}','{$nowtme}','" . $cuserLogin->getUserID() . "');\r\n \t";
$dsql->ExecuteNoneQuery($inquery);
$fid = $dsql->GetLastID();
AddMyAddon($fid, $imgsrcValue);
} else {
$imgsrcValue = $bfilename;
示例5: GetImageMapDD
/**
* 图集里大图的小图
*
* @access public
* @param string $filename 图片名称
* @param string $maxwidth 最大宽度
* @return string
*/
function GetImageMapDD($filename, $maxwidth)
{
global $cuserLogin, $dsql, $cfg_ddimg_height, $cfg_ddimg_full;
$ddn = substr($filename, -3);
$ddpicok = preg_replace("#\\." . $ddn . "\$#", "-lp." . $ddn, $filename);
$toFile = $GLOBALS['cfg_basedir'] . $ddpicok;
if ($cfg_ddimg_full == 'Y') {
ImageResizeNew($GLOBALS['cfg_basedir'] . $filename, $maxwidth, $cfg_ddimg_height, $toFile);
} else {
ImageResize($GLOBALS['cfg_basedir'] . $filename, $maxwidth, $cfg_ddimg_height, $toFile);
}
//保存图片附件信息
$fsize = filesize($toFile);
$ddpicoks = explode('/', $ddpicok);
$filename = $ddpicoks[count($ddpicoks) - 1];
$inquery = "INSERT INTO `#@__uploads`(arcid,title,url,mediatype,width,height,playtime,filesize,uptime,mid)\n VALUES ('0','{$filename}','{$ddpicok}','1','0','0','0','{$fsize}','" . time() . "','" . $cuserLogin->getUserID() . "'); ";
$dsql->ExecuteNoneQuery($inquery);
$fid = $dsql->GetLastID();
AddMyAddon($fid, $ddpicok);
return $ddpicok;
}
示例6: MemberUploads
function MemberUploads($upname, $handname, $userid = 0, $utype = 'image', $exname = '', $maxwidth = 0, $maxheight = 0, $water = false, $isadmin = false)
{
global $cfg_imgtype, $cfg_mb_addontype, $cfg_mediatype, $cfg_user_dir, $cfg_basedir, $cfg_dir_purview;
//当为游客投稿的情况下,这个 id 为 0
if (empty($userid)) {
$userid = 0;
}
if (!is_dir($cfg_basedir . $cfg_user_dir . "/{$userid}")) {
MkdirAll($cfg_basedir . $cfg_user_dir . "/{$userid}", $cfg_dir_purview);
CloseFtp();
}
//有上传文件
$allAllowType = str_replace('||', '|', $cfg_imgtype . '|' . $cfg_mediatype . '|' . $cfg_mb_addontype);
if (!empty($GLOBALS[$upname]) && is_uploaded_file($GLOBALS[$upname])) {
$nowtme = time();
$GLOBALS[$upname . '_name'] = trim(ereg_replace("[ \r\n\t\\*\\%\\/\\?><\\|\":]{1,}", '', $GLOBALS[$upname . '_name']));
//源文件类型检查
if ($utype == 'image') {
if (!eregi("\\.(" . $cfg_imgtype . ")\$", $GLOBALS[$upname . '_name'])) {
ShowMsg("你所上传的图片类型不在许可列表,请上传{$cfg_imgtype}类型!", '-1');
exit;
}
$sparr = array("image/pjpeg", "image/jpeg", "image/gif", "image/png", "image/xpng", "image/wbmp");
$imgfile_type = strtolower(trim($GLOBALS[$upname . '_type']));
if (!in_array($imgfile_type, $sparr)) {
ShowMsg('上传的图片格式错误,请使用JPEG、GIF、PNG、WBMP格式的其中一种!', '-1');
exit;
}
} else {
if ($utype == 'flash' && !eregi("\\.swf\$", $GLOBALS[$upname . '_name'])) {
ShowMsg('上传的文件必须为flash文件!', '-1');
exit;
} else {
if ($utype == 'media' && !eregi("\\.(" . $cfg_mediatype . ")\$", $GLOBALS[$upname . '_name'])) {
ShowMsg('你所上传的文件类型必须为:' . $cfg_mediatype, '-1');
exit;
} else {
if (!eregi("\\.(" . $allAllowType . ")\$", $GLOBALS[$upname . '_name'])) {
ShowMsg("你所上传的文件类型不被允许!", '-1');
exit;
}
}
}
}
//再次严格检测文件扩展名是否符合系统定义的类型
$fs = explode('.', $GLOBALS[$upname . '_name']);
$sname = $fs[count($fs) - 1];
$alltypes = explode('|', $allAllowType);
if (!in_array(strtolower($sname), $alltypes)) {
ShowMsg('你所上传的文件类型不被允许!', '-1');
exit;
}
//强制禁止的文件类型
if (eregi("\\.(asp|php|pl|cgi|shtm|js)", $sname)) {
ShowMsg('你上传的文件为系统禁止的类型!', '-1');
exit;
}
if ($exname == '') {
$filename = $cfg_user_dir . "/{$userid}/" . dd2char($nowtme . '-' . mt_rand(1000, 9999)) . '.' . $sname;
} else {
$filename = $cfg_user_dir . "/{$userid}/{$exname}." . $sname;
}
move_uploaded_file($GLOBALS[$upname], $cfg_basedir . $filename) or die("上传文件到 {$filename} 失败!");
@unlink($GLOBALS[$upname]);
if (@filesize($cfg_basedir . $filename) > $GLOBALS['cfg_mb_upload_size'] * 1024) {
@unlink($cfg_basedir . $filename);
ShowMsg('你上传的文件超出系统大小限制!', '-1');
exit;
}
//加水印或缩小图片
if ($utype == 'image') {
include_once DEDEINC . '/image.func.php';
if ($maxwidth > 0 || $maxheight > 0) {
ImageResize($cfg_basedir . $filename, $maxwidth, $maxheight);
} else {
if ($water) {
WaterImg($cfg_basedir . $filename);
}
}
}
return $filename;
} else {
//强制禁止的文件类型
if ($handname == '') {
return $handname;
} else {
if (eregi("\\.(asp|php|pl|cgi|shtm|js)", $handname)) {
exit('Not allow filename for not safe!');
} else {
if (!eregi("\\.(" . $allAllowType . ")\$", $handname)) {
exit('Not allow filename for filetype!');
} else {
if (!eregi('^http:', $handname) && !eregi('^' . $cfg_user_dir . '/' . $userid, $handname) && !$isadmin) {
exit('Not allow filename for not userdir!');
}
}
}
}
return $handname;
}
//.........这里部分代码省略.........
示例7: GetRemPic
$row = $dosql->GetOne("SELECT `parentid` FROM `#@__infoclass` WHERE `id`={$classid}");
$parentid = $row['parentid'];
if ($parentid == 0) {
$parentstr = '0,';
} else {
$r = $dosql->GetOne("SELECT `parentstr` FROM `#@__infoclass` WHERE `id`={$parentid}");
$parentstr = $r['parentstr'] . $parentid . ',';
}
//保存远程缩略图
if ($rempic == 'true' && preg_match("#^http:\\/\\/#i", $picurl)) {
$picurl = GetRemPic($picurl);
}
//自动缩略图处理
$r = $dosql->GetOne("SELECT `picwidth`,`picheight` FROM `#@__infoclass` WHERE `id`={$classid}");
if (!empty($r['picwidth']) && !empty($r['picheight'])) {
ImageResize(PHPMYWIND_ROOT . '/' . $picurl, $r['picwidth'], $r['picheight']);
}
$posttime = GetMkTime($posttime);
//自定义字段处理
$fieldname = '';
$fieldvalue = '';
$fieldstr = '';
$ids = GetDiyFieldCatePriv($modelid, $classid);
if (!empty($ids)) {
$dosql->Execute("SELECT * FROM `#@__diyfield` WHERE infotype={$modelid} AND `id` IN ({$ids}) AND checkinfo=true ORDER BY orderid ASC");
while ($row = $dosql->GetArray()) {
$k = $row['fieldname'];
if (isset($_POST[$row['fieldname']])) {
if (is_array($_POST[$row['fieldname']])) {
foreach ($_POST[$row['fieldname']] as $post_value) {
$v[] = addslashes($post_value);
示例8: seo_title
$lokasi_file = $_FILES['fupload']['tmp_name'];
$tipe_file = $_FILES['fupload']['type'];
$nama_file = $_FILES['fupload']['name'];
$judul_seo = seo_title($_POST['nama']);
$judul = substr($judul_seo, 0, 50);
$acak = rand(00, 999);
$nama_file_unik = 'cincin-kawin-perak-' . $acak . '-' . $judul . '-' . $nama_file;
if (!empty($lokasi_file)) {
if ($tipe_file != "image/jpeg" and $tipe_file != "image/pjpeg" and $tipe_file != "image/gif" and $tipe_file != "image/png") {
?>
<script>window.alert("Upload Gagal, Pastikan File yang di Upload bertipe *.JPG, *.GIF, *.PNG");
window.location=("../../media.php?module=<?php
echo $module . '&act=edit&id=' . $_POST['id'];
?>
")</script>;
<?php
die;
}
ImageUpload($fupload_name = $nama_file_unik, $to_dir = '../../../joimg/produk/');
//resize image
ImageResize($fupload_name = $nama_file_unik, $from_dir = '../../../joimg/produk/', $to_dir = '../../../joimg/produk/small/', $resize = '170');
mysql_query("INSERT INTO produk\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\tid_kategori,\n\t\t\t\t\t\t\t\t\tkodeproduk,\n\t\t\t\t\t\t\t\t\tnama,\n\t\t\t\t\t\t\t\t\tnama_seo,\n\t\t\t\t\t\t\t\t\tisi,\n\t\t\t\t\t\t\t\t\tharga,\n\t\t\t\t\t\t\t\t\tgambar\n\t\t\t\t\t\t\t\t) \n\t \t\tVALUES \t\n\t \t\t\t\t(\n\t \t\t\t\t\t'{$_POST['kategori']}',\n\t \t\t\t\t\t'{$_POST['kodeproduk']}',\n\t \t\t\t\t\t'{$_POST['nama']}',\n\t\t\t\t\t\t\t\t\t'{$judul_seo}',\n\t\t\t\t\t\t\t\t\t'{$text}',\n\t\t\t\t\t\t\t\t\t'{$_POST['harga']}',\n\t\t\t\t\t\t\t\t\t'{$nama_file_unik}'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t");
} else {
mysql_query("INSERT INTO produk\n\t\t\t\t\t\t\t\t(\n\t\t\t\t\t\t\t\t\tid_kategori,\n\t\t\t\t\t\t\t\t\tkodeproduk,\n\t\t\t\t\t\t\t\t\tnama,\n\t\t\t\t\t\t\t\t\tnama_seo,\n\t\t\t\t\t\t\t\t\tisi,\n\t\t\t\t\t\t\t\t\tharga\n\t\t\t\t\t\t\t\t) \n\t \t\tVALUES \t\n\t \t\t\t\t(\n\t \t\t\t\t\t'{$_POST['kategori']}',\n\t \t\t\t\t\t'{$_POST['kodeproduk']}',\n\t \t\t\t\t\t'{$_POST['nama']}',\n\t\t\t\t\t\t\t\t\t'{$judul_seo}',\n\t\t\t\t\t\t\t\t\t'{$text}',\n\t\t\t\t\t\t\t\t\t'{$_POST['harga']}'\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t");
}
echo "<script>alert('Sukses! Data Telah Berhasil Disimpan.'); window.location = '../../media.php?module={$module}';</script>";
} else {
echo "<script>alert('Maaf! Data Gagal Disimpan, Silahkan coba lagi.'); window.location = '../../media.php?module={$module}';</script>";
}
}
}
示例9: GetImageMapDD
/**
* 图集里大图的小图
*
* @param string $filename 文件名
* @param string $ddm 缩略图
* @param string $oldname 旧的名称
* @return string
*/
function GetImageMapDD($filename, $ddm, $oldname = '')
{
if ($oldname != '' && !preg_match("#^http:\\/\\/#i", $oldname)) {
$ddpicok = $oldname;
} else {
$ddn = substr($filename, -3);
$ddpicok = preg_replace("#\\." . $ddn . "\$#", "-lp." . $ddn, $filename);
}
$toFile = $GLOBALS['cfg_basedir'] . $ddpicok;
ImageResize($GLOBALS['cfg_basedir'] . $filename, $ddm, 300, $toFile);
return $ddpicok;
}
示例10: GetUpImage
function GetUpImage($litpic,$isdd=false,$exitErr=false,$iw=0,$ih=0,$iname='')
{
global $cfg_ml,$cfg_ddimg_width,$cfg_ddimg_height;
global $cfg_basedir,$cfg_user_dir,$title,$cfg_mb_upload_size,$cfg_photo_typenames;
if($iw==0) $iw = $cfg_ddimg_width;
if($ih==0) $ih = $cfg_ddimg_height;
$ntime = $nowtme = mytime();
if(!isset($_FILES[$litpic])) return "";
if(is_uploaded_file($_FILES[$litpic]['tmp_name']))
{
//超过限定大小的文件不给上传
if($_FILES[$litpic]['size'] > $cfg_mb_upload_size*1024){
@unlink($_FILES[$litpic]['tmp_name']);
return "";
}
$sparr = $cfg_photo_typenames;
$_FILES[$litpic]['type'] = strtolower(trim($_FILES[$litpic]['type']));
if(!in_array($_FILES[$litpic]['type'],$sparr)){
if($exitErr){
ShowMsg("上传的缩略图片格式错误,请使用JPEG、GIF、PNG格式的其中一种!","-1");
exit();
}else{ return ""; }
}
$savepath = $cfg_user_dir."/".$cfg_ml->M_ID;
CreateDir($savepath);
if($iname=='') $itname = dd2char($cfg_ml->M_ID."0".strftime("%y%m%d%H%M%S",$nowtme)."0".mt_rand(1000,9999)).'-lit';
else $itname = $iname;
$fullUrl = $savepath."/".$itname;
//强制检测文件类型
if($iname==''){
if(strtolower($_FILES[$litpic]['type'])=="image/gif") $fullUrl = $fullUrl.".gif";
else if(strtolower($_FILES[$litpic]['type'])=="image/png") $fullUrl = $fullUrl.".png";
else $fullUrl = $fullUrl.".jpg";
}else{
$fullUrl = $fullUrl.'.jpg';
}
@move_uploaded_file($_FILES[$litpic]['tmp_name'],$cfg_basedir.$fullUrl);
$litpic = $fullUrl;
if($isdd) @ImageResize($cfg_basedir.$fullUrl,$iw,$ih);
else @WaterImg($cfg_basedir.$fullUrl,'up');
//保存用户上传的记录到数据库
if($title==''){
if($isdd) $title = '用户上传的图片';
else $title = '用户上传的略略图';
}
$info = "";
$datas[0] = 0;
$datas[1] = 0;
$datas = GetImageSize($cfg_basedir.$fullUrl,$info);
$addinfos[0] = $datas[0];
$addinfos[1] = $datas[1];
$addinfos[2] = filesize($cfg_basedir.$fullUrl);
SaveUploadInfo($title,$fullUrl,1,$addinfos);
return $litpic;
}else{
return "";
}
}
示例11: getimagesize
if(file_exists($fullfilename)){
ShowMsg("本目录已经存在同名的文件,请更改!","-1");
exit();
}
if(!eregi("\.(jpg|gif|png|bmp)$",$fullfilename)){
ShowMsg("你所上传的文件类型被禁止,系统只允许上传jpg、gif、png、bmp类型图片!","-1");
exit();
}
@move_uploaded_file($imgfile,$fullfilename);
if(empty($resize)) $resize = 0;
if($resize==1){
if(in_array($imgfile_type,$cfg_photo_typenames)) ImageResize($fullfilename,$iwidth,$iheight);
}
else{
if(in_array($imgfile_type,$cfg_photo_typenames)) WaterImg($fullfilename,'up');
}
$info = "";
$sizes[0] = 0; $sizes[1] = 0;
@$sizes = getimagesize($fullfilename,$info);
$imgwidthValue = $sizes[0];
$imgheightValue = $sizes[1];
$imgsize = filesize($fullfilename);
$inquery = "
INSERT INTO #@__uploads(title,url,mediatype,width,height,playtime,filesize,uptime,adminid,memberid)
VALUES ('$filename','".$activepath."/".$filename."','1','$imgwidthValue','$imgheightValue','0','{$imgsize}','{$nowtme}','".$cuserLogin->getUserID()."','0');
示例12: _before_edit
public function _before_edit()
{
if ($_FILES) {
import("ORG.Net.UploadFile");
$upload = new UploadFile();
//设置上传文件大小
$upload->maxSize = 3145728;
//设置上传文件类型
$upload->allowExts = array('jpg', 'gif', 'png', 'jpeg');
$upload->saveRule = 'uniqid';
$dir = get_dir($_POST['id']);
$path = $upload->savePath = C('IMG_ROOT') . 'avatar/' . $dir . '/';
mk_dir($upload->savePath);
$upload->upload();
$info = $upload->getUploadFileInfo();
if ($info != "") {
foreach ($info as $file) {
//图片调整大小
$imginfo = getimagesize($path . $file['savename']);
$width = $imginfo[0];
$height = $imginfo[1];
//缩略图2(250*250)
$full_blitfilename2 = $path . 'm.jpg';
copy($path . $file['savename'], $full_blitfilename2);
ImageResize($full_blitfilename2, 120, 120);
//缩略图2(250*250)
$full_blitfilename3 = $path . 's.jpg';
copy($path . $file['savename'], $full_blitfilename3);
ImageResize($full_blitfilename3, 64, 64);
//原图
$full_blitfilename = $path . 'b.jpg';
rename($path . $file['savename'], $full_blitfilename);
$key = $file['key'];
$_POST[$key] = C('IMG_URL') . 'avatar/' . $dir . '/m.jpg';
}
}
}
}
示例13: DownMedia
function DownMedia($dourl,$mtype='img'){
//检测是否已经下载此文件
$isError = false;
$errfile = $GLOBALS['cfg_phpurl'].'/img/etag.gif';
$row = $this->dsql->GetOne("Select nurl from #@__co_mediaurl where rurl like '$dourl'");
$wi = false;
if(!empty($row['nurl'])){
$filename = $row['nurl'];
return $filename;
}else{
//如果不存在,下载该文件
$filename = $this->GetRndName($dourl,$mtype);
if(!ereg("^/",$filename)) $filename = "/".$filename;
//反盗链模式
if($this->Item["isref"]=='yes' && $this->Item["refurl"]!=''){
if($this->Item["exptime"]=='') $this->Item["exptime"] = 10;
$rs = DownImageKeep($dourl,$this->Item["refurl"],$GLOBALS['cfg_basedir'].$filename,"",0,$this->Item["exptime"]);
if($rs){
$inquery = "INSERT INTO #@__co_mediaurl(nid,rurl,nurl) VALUES ('".$this->NoteId."', '".addslashes($dourl)."', '".addslashes($filename)."');";
$this->dsql->ExecuteNoneQuery($inquery);
}else{
$inquery = "INSERT INTO #@__co_mediaurl(nid,rurl,nurl) VALUES ('".$this->NoteId."', '".addslashes($dourl)."', '".addslashes($errfile)."');";
$this->dsql->ExecuteNoneQuery($inquery);
$isError = true;
}
if($mtype=='img'){ $wi = true; }
//常规模式
}else{
$this->CHttpDown->OpenUrl($dourl);
$this->CHttpDown->SaveToBin($GLOBALS['cfg_basedir'].$filename);
$inquery = "INSERT INTO #@__co_mediaurl(nid,rurl,nurl) VALUES ('".$this->NoteId."', '".addslashes($dourl)."', '".addslashes($filename)."');";
$this->dsql->ExecuteNoneQuery($inquery);
if($mtype=='img'){ $wi = true; }
$this->CHttpDown->Close();
}
}
//生成缩略图
if($mtype=='img' && $this->breImage=='' && !$isError){
$this->breImage = $filename;
if(!eregi("^http://",$this->breImage) && file_exists($GLOBALS['cfg_basedir'].$filename)){
$filenames = explode('/',$filename);
$filenamed = $filenames[count($filenames)-1];
$nfilename = "lit_".$filenamed;
$nfilename = str_replace($filenamed,$nfilename,$filename);
if(file_exists($GLOBALS['cfg_basedir'].$nfilename)){
$this->breImage = $nfilename;
}else if(copy($GLOBALS['cfg_basedir'].$filename,$GLOBALS['cfg_basedir'].$nfilename)){
ImageResize($GLOBALS['cfg_basedir'].$nfilename,$GLOBALS['cfg_ddimg_width'],$GLOBALS['cfg_ddimg_height']);
$this->breImage = $nfilename;
}
}
}
if($wi && !$isError) @WaterImg($GLOBALS['cfg_basedir'].$filename,'up');
if(!$isError) return $filename;
else return $errfile;
}
示例14: AR_UploadImage
/**
* Function to upload and extract the image
* This function is made custumize
* */
function AR_UploadImage($strFldName, $arrDestination, $arrSize, $strPrefix = '', $oldFileName = '', $arrAllowedTypes = '', $forceresize = 0, $version = 0)
{
//echo $oldFileName;die();
$strReturn = false;
//var_dump($arrOldData);
//For photo field ********************
//$strFldName = $this->tbl_prefix.'file';
if ($version == 0) {
$strFileField = $strPrefix . $strFldName;
} elseif ($version == 1) {
$strFileField = $strFldName;
}
if (isset($_FILES[$strFileField]) && $_FILES[$strFileField]['size'] > 0) {
$tmpName = $_FILES[$strFileField]['tmp_name'];
$fileType = $_FILES[$strFileField]['type'];
$fileExt = substr($_FILES[$strFileField]['name'], strrpos($_FILES[$strFileField]['name'], '.'));
if ($oldFileName == '') {
$newFileName = getTimeStamp() . $fileExt;
} else {
if ($fileExt == substr($oldFileName, -strlen($fileExt))) {
$newFileName = $oldFileName;
} else {
$newFileName = getTimeStamp() . $fileExt;
}
}
$tmpLoc = UPLOADS_DIR;
$destLoc = $arrDestination;
$extOnly = substr($fileExt, 1);
//echo $extOnly;
//Check the file type
if (is_array($arrAllowedTypes)) {
if (!in_array($extOnly, $arrAllowedTypes)) {
return array(false, 'Invalid File Type...');
}
} elseif ($arrAllowedTypes != '' && $arrAllowedTypes !== $extOnly) {
return array(false, 'Invalid File Type...');
} else {
$arrAllowedTypes = array('jpg', 'jpeg', 'gif', 'png');
if (!in_array($extOnly, $arrAllowedTypes)) {
return array(false, 'Invalid File Type...');
}
}
if (move_uploaded_file($tmpName, $tmpLoc . $newFileName)) {
ImageResize($tmpLoc . $newFileName, $destLoc . $newFileName, $arrSize[0], $arrSize[1], $forceresize);
if (copy($destLoc . $newFileName, $destLoc . 'thumb/' . $newFileName)) {
ar_image_forceresize($destLoc . 'thumb/' . $newFileName, THUMB_W, THUMB_H);
} else {
echo 'Thumb Not Created !';
}
//ar_imageresize($destLoc.$newFileName,$arrSize[0],$arrSize[1]);
//Single string with location...
//copy( $tmpLoc.$newFileName, $destLoc.$newFileName );
unlink($tmpLoc . $newFileName);
}
$strReturn = array(true, $newFileName);
//if old data then delete the old file
} else {
$strReturn = array('false', $_FILES[$strFileField]['size']);
}
return $strReturn;
}
示例15: imagejpeg
case 'image/jpeg':
imagejpeg($thumba, $ddpicokurl, 85);
break;
case 'image/gif':
imagegif($thumba, $ddpicokurl);
break;
case 'image/png':
imagepng($thumba, $ddpicokurl);
break;
default:
ShowMsg("对不起,裁剪图片类型不支持请选择其他类型图片!", "-1");
break;
}
//对任意裁剪方式再次缩小图片至限定大小
if ($newwidth > $cfg_ddimg_width || $newheight > $cfg_ddimg_height) {
ImageResize($ddpicokurl, $cfg_ddimg_width, $cfg_ddimg_height);
}
//如果从其它图中剪出, 保存附件信息
if (empty($isupload)) {
$inquery = "INSERT INTO `#@__uploads`(title,url,mediatype,width,height,playtime,filesize,uptime,mid)\n VALUES ('{$ddpicok}','{$ddpicok}','1','0','0','0','" . filesize($ddpicokurl) . "','" . time() . "','" . $cuserLogin->getUserID() . "'); ";
$dsql->ExecuteNoneQuery($inquery);
$fid = $dsql->GetLastID();
AddMyAddon($fid, $ddpicok);
}
?>
<SCRIPT language=JavaScript>
function ReturnImg(reimg)
{
<?php
echo $reObjJs;
?>