#*********************************************************
#文件名称:
inc_class.upload.php
#Copyright (c)
2007-2009 青春一度 all rights reserved.
#最后更新: 2009-08-05
#版本 : v 2.0.a
#注:转发时请保留此声明信息,这段声明不并会影响你的速度!
#如有修改请将修改后的文件以邮件形式发送给作者一份,谢谢!
#
#*********************************************************
if(!defined('IN_PHPADLEYIU'))
{
exit('Access Denied');
}
/*
//使用说明:
//声明一个上传类
include_once(ADLEYLIU_ROOT.'./inc_class.upload.php');
$_YL_UPLOAD
= array();
$yl_uploadfile = new
yl_upload_class();
$_YL_UPLOAD['yl_filedata'] =
'uploadFile';//表单名
$_YL_UPLOAD['yl_directroy'] =
'upload_files';//上传主目录
$_YL_UPLOAD['file_urldirectroy'] = '/';//
程序路径
$_YL_UPLOAD['yl_settingsnew'] =
''.date('ym').'/'.date('d').'/'.substr(time(), 0,
5).'';//上传子主目录
$_YL_UPLOAD['yl_maxsize'] = 1048576;
//这里以字节为单位(1024*2)*1024=2097152 就是 2M
$_YL_UPLOAD['yl_sizeformat'] =
'k'; //显示文件大小单位b字节,k千,m兆
$_YL_UPLOAD['yl_arrext'] =
array('gif','jpg','jpeg','png','bmp','rar','txt');//允许上传文件类型
$_YL_UPLOAD['yl_ext'] = 0; //0原文件类型上传,1统一为存为jpg
$_YL_UPLOAD['yl_prefix'] = ''.$uid.''.$yl_uploadfile -> yl_createrand(1,0).''.$cid.'';
//在文件名前缀加上特殊字符 //$uid 会员ID $cid 分类ID
$_YL_UPLOAD['yl_suffix'] = ''; //''.$yl_uploadfile -> yl_createrand(3,0).'';
//在文件名后缀加上特殊字符
$_YL_UPLOAD['thumbwidth'] = 100;
//缩略图宽
$_YL_UPLOAD['thumbheight'] = 100;
//缩略图高
$_YL_UPLOAD['maxthumbwidth'] = 500;
//大图高
$_YL_UPLOAD['maxthumbheight'] = 500;
//大图宽
//上传
$yl_uploadfile -> yl_uploadfile();
获取值:
'yl_filename' => addslashes($_YL_UPLOAD['yl_filename']),原文件名
'yl_attachment' => $_YL_UPLOAD['yl_attachment'],新文件名及路径
'yl_filesize' => $_YL_UPLOAD['yl_filesize'] ,文件大小
'yl_filetype' => $_YL_UPLOAD['yl_filetype'],文件类型
'yl_isimage' => $_YL_UPLOAD['yl_isimage'],是否是图片
'yl_isthumb' => $_YL_UPLOAD['yl_isthumb'],是否有小图片
*/
class yl_upload_class
{
function __GET($property_name)
{
if(isset($this -> $property_name))
{
return $this -> $property_name;
} else
{
return
NULL;
}
}
function __SET($property_name,
$value) {
$this -> $property_name =
$value;
}
#*********************************************************
#生成缩略图
#*********************************************************
function makethumb($srcfile) {
global $_YL_UPLOAD;
//判断文件是否存在
if (!file_exists($srcfile))
{
return '';
}
$dstfile =
$srcfile.'.small.jpg';
$bigfile =
$srcfile.'.big.jpg';
//缩略图大小
$tow =
intval($_YL_UPLOAD['thumbwidth']);
$toh =
intval($_YL_UPLOAD['thumbheight']);
if($tow
60;
if($toh
$make_max = 0;
$maxtow =
intval($_YL_UPLOAD['maxthumbwidth']);
$maxtoh =
intval($_YL_UPLOAD['maxthumbheight']);
if($maxtow >= 300
&& $maxtoh >= 300) {
$make_max =
1;
}
//获取图片信息
$im = '';
if($data =
getimagesize($srcfile)) {
if($data[2] == 1)
{
$make_max =
0;//gif不处理
if(function_exists("imagecreatefromgif"))
{
$im =
imagecreatefromgif($srcfile);
}
}
elseif($data[2] == 2)
{
if(function_exists("imagecreatefromjpeg"))
{
$im =
imagecreatefromjpeg($srcfile);
}
}
elseif($data[2] == 3)
{
if(function_exists("imagecreatefrompng"))
{
$im =
imagecreatefrompng($srcfile);
}
}
}
if(!$im)
return '';
$srcw = imagesx($im);
$srch = imagesy($im);
$towh = $tow/$toh;
$srcwh =
$srcw/$srch;
if($towh
$ftow =
$tow;
$ftoh = $ftow*($srch/$srcw);
$fmaxtow = $maxtow;
$fmaxtoh =
$fmaxtow*($srch/$srcw);
} else {
$ftoh =
$toh;
$ftow = $ftoh*($srcw/$srch);
$fmaxtoh = $maxtoh;
$fmaxtow =
$fmaxtoh*($srcw/$srch);
}
if($srcw
&& $srch
$make_max =
0;//不处理
}
if($srcw > $tow $srch > $toh)
{
if(function_exists("imagecreatetruecolor") &&
function_exists("imagecopyresampled") && @$ni =
imagecreatetruecolor($ftow, $ftoh))
{
imagecopyresampled($ni, $im, 0, 0, 0, 0, $ftow,
$ftoh, $srcw,
$srch);
//大图片
if($make_max
&& @$maxni = imagecreatetruecolor($fmaxtow, $fmaxtoh))
{
imagecopyresampled($maxni, $im, 0, 0, 0, 0,
$fmaxtow, $fmaxtoh, $srcw, $srch);
}else if (@$maxni
= imagecreatetruecolor(round($srcw/2),
round($srch/2))){
imagecopyresampled($maxni,
$im, 0, 0, 0, 0, round($srcw/2), round($srch/2), $srcw,
$srch);
}
}
elseif(function_exists("imagecreate") &&
function_exists("imagecopyresized") && @$ni = imagecreate($ftow, $ftoh))
{
imagecopyresized($ni, $im, 0, 0, 0, 0, $ftow,
$ftoh, $srcw,
$srch);
//大图片
if($make_max
&& @$maxni = imagecreate($fmaxtow, $fmaxtoh))
{
imagecopyresized($maxni, $im, 0, 0, 0, 0,
$fmaxtow, $fmaxtoh, $srcw, $srch);
}else if (@$maxni
= imagecreate(round($srcw/2),
round($srch/2))){
imagecopyresized($maxni, $im,
0, 0, 0, 0, round($srcw/2), round($srch/2), $srcw,
$srch);
}
} else
{
return
'';
}
if(function_exists('imagejpeg'))
{
imagejpeg($ni,
$dstfile);
//大图片
if($make_max)
{
imagejpeg($maxni,
$bigfile);
}else{
imagejpeg($maxni,
$bigfile);
}
}
elseif(function_exists('imagepng')) {
imagepng($ni,
$dstfile);
//大图片
if($make_max)
{
imagepng($maxni,
$bigfile);
}else{
imagejpeg($maxni,
$bigfile);
}
}
imagedestroy($ni);
if($make_max)
{
}else{
imagedestroy($maxni);
}
}else{
if(function_exists("imagecreatetruecolor") &&
function_exists("imagecopyresampled") && @$ni =
imagecreatetruecolor($srcw, $srch))
{
imagecopyresampled($ni, $im, 0, 0, 0, 0, $srcw,
$ftoh, $srch,
$srch);
//大图片
$maxni =
imagecreatetruecolor($srch, $srch);
imagecopyresampled($maxni, $im, 0, 0, 0, 0, $srcw, $srch, $srcw,
$srch);
} elseif(function_exists("imagecreate")
&& function_exists("imagecopyresized") && @$ni =
imagecreate($ftow, $ftoh)) {
imagecopyresized($ni,
$im, 0, 0, 0, 0, $srcw, $srch, $srcw,
$srch);
//大图片
$maxni =
imagecreate($fmaxtow, $fmaxtoh);
imagecopyresized($maxni, $im, 0, 0, 0, 0, $srcw, $srch, $srcw,
$srch);
} else
{
return
'';
}
imagejpeg($ni, $dstfile);
imagejpeg($maxni,
$bigfile);
}
imagedestroy($im);
if(!file_exists($dstfile)) {
return
'';
} else {
return
$dstfile;
}
}
#*********************************************************
#获取随机数函数
#*********************************************************
function
yl_createrand($length, $numeric = 0) {
PHP_VERSION
&& mt_srand((double)microtime() * 1000000);
if($numeric)
{
$hash = sprintf('%0'.$length.'d', mt_rand(0, pow(10,
$length) - 1));
} else {
$hash =
'';
$chars =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';///0123456789
$max
= strlen($chars) - 1;
for($i = 0; $i
{
$hash .= $chars[mt_rand(0,
$max)];
}
}
return
$hash;
}
#***************
#*********************************************************
#创建目录函数
#*********************************************************
function
createfolder($yl_path)
{
if
(!file_exists($yl_path))
{
$this ->
createfolder(dirname($yl_path));
@mkdir($yl_path,
0777);
}
return $this ->
createfolder;
}
#*********************************************************
#获取文件
名称,大小,类型,临时文件名
#*********************************************************
function
yl_getfilename($yl_type)
{
global
$_YL_UPLOAD;
return
$_FILES[$_YL_UPLOAD['yl_filedata']][$yl_type];
}
#*********************************************************
#获取文件大小
#*********************************************************
function
yl_getfilesize()
{
global
$_YL_UPLOAD;
$yl_filesize = $this ->
yl_getfilename('size');
if($yl_filesize ==
0){
$this ->
alert("请选择上传文件!");
exit;
}
if($yl_filesize
> $_YL_UPLOAD['yl_maxsize']){
switch
(strtolower($_YL_UPLOAD['yl_sizeformat'])){
case
'b':
$yl_maxsizek = $_YL_UPLOAD['yl_maxsize'] .
' B';
break;
case
'k':
$yl_maxsizek =
$_YL_UPLOAD['yl_maxsize']/1024 . '
K';
break;
case
'm':
$yl_maxsizek =
$_YL_UPLOAD['yl_maxsize']/(1024*1024) . '
M';
}
$this ->
alert("上传文件超出限制范围[".$yl_maxsizek."].K!");
exit;
}
return
$yl_filesize;
}
#*********************************************************
#获得文件扩展名
#*********************************************************
function
yl_getfiletype()
{
global
$_YL_UPLOAD;
$pathinfo = pathinfo($this -> yl_getfilename('name'));
$yl_file_ext =
strtolower($pathinfo['extension']);
//检查扩展名
if(!array_keys($_YL_UPLOAD['yl_arrext'],$yl_file_ext))
{
$this ->
alert("上传文件类型被限制!");
exit;
}
return
$yl_file_ext;
}
#*********************************************************
#上传验证
#*********************************************************
function
yl_upfile($source, $target) {
//
如果一种函数上传失败,还可以用其他函数上传
if (function_exists('move_uploaded_file')
&& @move_uploaded_file($source, $target))
{
@chmod($target, 0666);
return
$target;
} elseif (@copy($source, $target))
{
@chmod($target, 0666);
return
$target;
} elseif (@is_readable($source))
{
if ($fp = @fopen($source,'rb'))
{
@flock($fp,2);
$filedata
=
@fread($fp,@filesize($source));
@fclose($fp);
}
if
($fp = @fopen($target, 'wb')) {
@flock($fp,
2);
@fwrite($fp,
$filedata);
@fclose($fp);
@chmod
($target, 0666);
return
$target;
} else {
return
false;
}
}
}
#*********************************************************
#上传
#*********************************************************
function
yl_uploadfile()
{
global $_YL_UPLOAD;
$yl_file_path = $_YL_UPLOAD['yl_directroy'].'/'.$_YL_UPLOAD['yl_settingsnew'] ;//建立一个目录
$yl_filename = $this -> yl_getfilename('name');//原文件名
$yl_filenamenews = $_YL_UPLOAD['yl_prefix'].''.substr(time(), 5, 9).''.$_YL_UPLOAD['yl_suffix'].'';//重命名
$yl_file_size = $this -> yl_getfilesize();//获取文件大小
$yl_file_type = $this -> yl_getfiletype();//获取文件类型
if($_YL_UPLOAD['yl_ext'] ==
0){
$yl_filenamenewsext = $yl_filenamenews.'.'.$yl_file_type;//改名
}elseif ($_YL_UPLOAD['yl_ext'] == 1){
$yl_filenamenewsext = $yl_filenamenews.'.jpg';//统一改名为jpg
}
//$yl_tmp_name = str_replace(' ','',$this ->
yl_getfilename('tmp_name'));//服务器上临时文件名
$yl_tmp_name = $this -> yl_getfilename('tmp_name');//服务器上临时文件名
//检查是否已上传
if(
href="!@is_uploaded_file($yl_tmp_name" _cke_saved_href="[email=!@is_uploaded_file($yl_tmp_name]!@is_uploaded_file($yl_tmp_name">mailto:!@is_uploaded_file($yl_tmp_name">!@is_uploaded_file($yl_tmp_name))
{
$this ->
alert("文件已上传!");
exit;
}
//检查目录是否存在,不存在则创建
if(
href="!@is_dir(''.$_YL_UPLOAD['file_urldirectroy'].''.$yl_file_path.''" _cke_saved_href="[email=!@is_dir(]!@is_dir(''.$_YL_UPLOAD['file_urldirectroy'].''.$yl_file_path.''">mailto:!@is_dir(''.$_YL_UPLOAD['file_urldirectroy'].''.$yl_file_path.''">!@is_dir(''.$_YL_UPLOAD['file_urldirectroy'].''.$yl_file_path.''))
{
$this ->
createfolder(''.$_YL_UPLOAD['file_urldirectroy'].''.$yl_file_path.'');//创建目录
}
//检查目录写权限
if
(
href="!@is_writable(''.$_YL_UPLOAD['file_urldirectroy'].''.$yl_file_path.''" _cke_saved_href="[email=!@is_writable(]!@is_writable(''.$_YL_UPLOAD['file_urldirectroy'].''.$yl_file_path.''">mailto:!@is_writable(''.$_YL_UPLOAD['file_urldirectroy'].''.$yl_file_path.''">!@is_writable(''.$_YL_UPLOAD['file_urldirectroy'].''.$yl_file_path.''))
{
$this ->
alert("上传目录没有写权限!");
exit;
}
$yl_path_name
=
''.$_YL_UPLOAD['file_urldirectroy'].''.$yl_file_path.'/'.$yl_filenamenewsext.'';
$yl_doupload = $this -> yl_upfile($yl_tmp_name, $yl_path_name);
if($yl_doUpload === false){
$this -> alert("上传失败!");
exit;
}else{
//echo
'上传成功';
//echo
'
';
/*
echo
'原文件名:'.$yl_filename.'';
echo
'
';
echo
'新文件名及目录:'.$yl_file_path.'/'.$yl_filenamenewsext;
echo
'
';
echo
'文件大小:'.$yl_file_size.'';
echo '
';
echo '文件类型:'.$yl_file_type.'';
*/
$_YL_UPLOAD['yl_filename'] = $yl_filename;
$_YL_UPLOAD['yl_attachment'] = ''.$yl_file_path.'/'.$yl_filenamenewsext.'';
$_YL_UPLOAD['yl_filesize'] = $yl_file_size;
$_YL_UPLOAD['yl_filetype'] = $yl_file_type;
//检查是否图片
if(@getimagesize($yl_path_name))
{
$_YL_UPLOAD['yl_isimage'] =
1;
///生成缩略图
if ($this -> makethumb($yl_path_name)){
$_YL_UPLOAD['yl_isthumb'] = 1;
}else{
$_YL_UPLOAD['yl_isthumb'] = 0;
}
}else{
$_YL_UPLOAD['yl_isimage'] = 0;
}
}
return
true;
}
#*********************************************************
#提示
#*********************************************************
function
alert($yl_msg)
{
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
echo ' <script></script>';
echo '';
echo '';
exit;
}
}

function是函数的意思,是一段具有特定功能的可重复使用的代码块,是程序的基本组成单元之一,可以接受输入参数,执行特定的操作,并返回结果,其目的是封装一段可重复使用的代码,提高代码的可重用性和可维护性。

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code<form name="myform"

MySQL.proc表的作用和功能详解MySQL是一种流行的关系型数据库管理系统,开发者在使用MySQL时常常会涉及到存储过程(StoredProcedure)的创建和管理。而MySQL.proc表则是一个非常重要的系统表,它存储了数据库中所有的存储过程的相关信息,包括存储过程的名称、定义、参数等。在本文中,我们将详细解释MySQL.proc表的作用和功能

在本文中,我们将了解enumerate()函数以及Python中“enumerate()”函数的用途。什么是enumerate()函数?Python的enumerate()函数接受数据集合作为参数并返回一个枚举对象。枚举对象以键值对的形式返回。key是每个item对应的索引,value是items。语法enumerate(iterable,start)参数iterable-传入的数据集合可以作为枚举对象返回,称为iterablestart-顾名思义,枚举对象的起始索引由start定义。如果我们忽

Vue.use函数的用法和作用Vue是一款流行的前端框架,它提供了许多有用的功能和功能。其中之一就是Vue.use函数,它可以让我们在Vue应用中使用插件。本文将介绍Vue.use函数的用法和作用,并且提供一些代码示例。Vue.use函数的基本用法非常简单,只需在Vue实例化之前调用它,并传入要使用的插件作为参数。下面是一个简单的示例://引入并使用插件

file_exists方法检查文件或目录是否存在。它接受要检查的文件或目录的路径作为参数。以下是它的用途-当您需要在处理之前知道文件是否存在时,它非常有用。这样,在创建新文件时使用此函数即可知道该文件是否已存在。语法file_exists($file_path)参数file_path-设置要检查是否存在的文件或目录的路径。必需。返回file_exists()方法返回。如果文件或目录存在,则返回TrueFalse,如果文件或目录不存在示例让我们看一个检查“candidate.txt”文件和即使文件

js函数function用法有:1、声明函数;2、调用函数;3、函数参数;4、函数返回值;5、匿名函数;6、函数作为参数;7、函数作用域;8、递归函数。

随着互联网的发展,SOA(面向服务的架构)已经成为了当今企业级系统中的一种重要的技术架构。SOA架构中的服务可以被重复使用、重组和扩展,同时还能够简化系统开发和维护的过程。PHP作为一种被广泛使用的Web编程语言,也提供了一些用于实现SOA的函数库。接下来,我们将详细介绍如何在PHP中使用SOA函数。一、SOA的基本概念SOA是一种分布式系统开发的思想和架构


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는

PhpStorm 맥 버전
최신(2018.2.1) 전문 PHP 통합 개발 도구

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

MinGW - Windows용 미니멀리스트 GNU
이 프로젝트는 osdn.net/projects/mingw로 마이그레이션되는 중입니다. 계속해서 그곳에서 우리를 팔로우할 수 있습니다. MinGW: GCC(GNU Compiler Collection)의 기본 Windows 포트로, 기본 Windows 애플리케이션을 구축하기 위한 무료 배포 가능 가져오기 라이브러리 및 헤더 파일로 C99 기능을 지원하는 MSVC 런타임에 대한 확장이 포함되어 있습니다. 모든 MinGW 소프트웨어는 64비트 Windows 플랫폼에서 실행될 수 있습니다.

ZendStudio 13.5.1 맥
강력한 PHP 통합 개발 환경
