本文整理匯總了PHP中cls_image::random_filename方法的典型用法代碼示例。如果您正苦於以下問題:PHP cls_image::random_filename方法的具體用法?PHP cls_image::random_filename怎麽用?PHP cls_image::random_filename使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cls_image
的用法示例。
在下文中一共展示了cls_image::random_filename方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: get_img
function get_img($img_url = '')
{
$cls_imageobj = new cls_image();
$data = file_get_contents($img_url);
$dir = date('Ym');
$filename = cls_image::random_filename();
$imgDir = $cls_imageobj->images_dir . '/' . $dir . '/source_img/' . $filename . '.jpg';
$dir = ROOT_PATH . $imgDir;
$fp = @fopen($dir, "w");
@fwrite($fp, $data);
fclose($fp);
return $imgDir;
}
示例2: array
$old_original_img = '';
// 初始化原始圖片舊圖
// 如果上傳了商品圖片,相應處理
if ($_FILES['goods_img']['tmp_name'] != '' && $_FILES['goods_img']['tmp_name'] != 'none') {
$original_img = $image->upload_image($_FILES['goods_img']);
// 原始圖片
if ($original_img === false) {
sys_msg($image->error_msg(), 1, array(), false);
}
$goods_img = $original_img;
// 商品圖片
/* 複製一份相冊圖片 */
$img = $original_img;
// 相冊圖片
$pos = strpos(basename($img), '.');
$newname = dirname($img) . '/' . $image->random_filename() . substr(basename($img), $pos);
if (!copy('../' . $img, '../' . $newname)) {
sys_msg('fail to copy file: ' . realpath('../' . $img), 1, array(), false);
}
$img = $newname;
$gallery_img = $img;
$gallery_thumb = $img;
// 如果係統支持GD,縮放商品圖片,且給商品圖片和相冊圖片加水印
if ($image->gd_version() > 0 && $image->check_img_function($_FILES['goods_img']['type'])) {
// 如果設置大小不為0,縮放圖片
if ($_CFG['image_width'] != 0 || $_CFG['image_height'] != 0) {
$goods_img = $image->make_thumb('../' . $goods_img, $GLOBALS['_CFG']['image_width'], $GLOBALS['_CFG']['image_height']);
if ($goods_img === false) {
sys_msg($image->error_msg(), 1, array(), false);
}
}
示例3: unique_name
/**
* 生成指定目錄不重名的文件名
*
* @access public
* @param string $dir 要檢查是否有同名文件的目錄
*
* @return string 文件名
*/
function unique_name($dir)
{
$filename = '';
while (empty($filename)) {
$filename = cls_image::random_filename();
if (is_file($dir . $filename . '.jpg') || file_exists($dir . $filename . '.gif') || is_file($dir . $filename . '.png')) {
$filename = '';
}
}
return $filename;
}
示例4: upload_article_file
function upload_article_file($upload)
{
if (!make_dir("../" . DATA_DIR . "/article")) {
/* 創建目錄失敗 */
return false;
}
$filename = cls_image::random_filename() . substr($upload['name'], strpos($upload['name'], '.'));
$path = ROOT_PATH . DATA_DIR . "/article/" . $filename;
if (move_upload_file($upload['tmp_name'], $path)) {
return DATA_DIR . "/article/" . $filename;
} else {
return false;
}
}
示例5: array
$field_arr['goods_number'] = 0;
}
$db->autoExecute($ecs->table('goods'), $field_arr, 'INSERT');
$max_id = $db->insert_id() + 1;
/* 如果圖片不為空,修改商品圖片,插入商品相冊*/
if (!empty($field_arr['original_img']) || !empty($field_arr['goods_img']) || !empty($field_arr['goods_thumb'])) {
$goods_img = '';
$goods_thumb = '';
$original_img = '';
$goods_gallery = array();
$goods_gallery['goods_id'] = $db->insert_id();
if (!empty($field_arr['original_img'])) {
//設置商品相冊原圖和商品相冊圖
if ($_CFG['auto_generate_gallery']) {
$ext = substr($field_arr['original_img'], strrpos($field_arr['original_img'], '.'));
$img = dirname($field_arr['original_img']) . '/' . $image->random_filename() . $ext;
$gallery_img = dirname($field_arr['original_img']) . '/' . $image->random_filename() . $ext;
@copy(ROOT_PATH . $field_arr['original_img'], ROOT_PATH . $img);
@copy(ROOT_PATH . $field_arr['original_img'], ROOT_PATH . $gallery_img);
$goods_gallery['img_original'] = reformat_image_name('gallery', $goods_gallery['goods_id'], $img, 'source');
}
//設置商品原圖
if ($_CFG['retain_original_img']) {
$original_img = reformat_image_name('goods', $goods_gallery['goods_id'], $field_arr['original_img'], 'source');
} else {
@unlink(ROOT_PATH . $field_arr['original_img']);
}
}
if (!empty($field_arr['goods_img'])) {
//設置商品相冊圖
if ($_CFG['auto_generate_gallery'] && !empty($gallery_img)) {
示例6: get_img
/**
* 處理url圖片
* @$img_url 圖片地址
* @$mark 是否處理縮略圖 1不處理
**/
function get_img($img_url = '', $mark = '0')
{
$cls_imageobj = new cls_image();
if (strstr($img_url, 'http://')) {
$data = file_get_contents($img_url);
$dir = date('Ym');
$filename = cls_image::random_filename();
$imgDir = $cls_imageobj->images_dir . '/' . $dir . '/source_img/' . $filename . '.jpg';
$dir = ROOT_PATH . $imgDir;
$fp = @fopen($dir, "w");
@fwrite($fp, $data);
fclose($fp);
} else {
$imgDir = $img_url;
}
if ($mark == '0') {
//處理縮略圖
$goods_thumb = '';
$goods_img = '';
$goods_thumb = $cls_imageobj->make_thumb('http://o2o.txd168.com/' . $imgDir, "170", '170');
$goods_img = $cls_imageobj->make_thumb('http://o2o.txd168.com/' . $imgDir, "300", '300');
return array('original_img' => $imgDir, 'goods_thumb' => $goods_thumb, 'goods_img' => $goods_img);
} elseif ($mark == '1') {
return $imgDir;
}
}