php图片上传实现代码
先了解files函数
$_files数组内容如下:
$_files['myfile']['name'] 客户端文件的原名称。
$_files['myfile']['type'] 文件的 mime 类型,需要浏览器提供该信息的支持,例如"image/gif"。
$_files['myfile']['size'] 已上传文件的大小,单位为字节。
$_files['myfile']['tmp_name'] 文件被上传后在服务端储存的临时文件名,一般是系统默认。可以在php教程.ini的upload_tmp_dir 指定,但 用 putenv() 函数设置是不起作用的。
$_files['myfile']['error'] 和该文件上传相关的错误代码。['error'] 是在 php 4.2.0 版本中增加的。下面是它的说明:(它们在php3.0以后成了常量)
upload_err_ok
值:0; 没有错误发生,文件上传成功。
upload_err_ini_size
值:1; 上传的文件超过了 php.ini 中 upload_max_filesize 选项限制的值。
upload_err_form_size
值:2; 上传文件的大小超过了 html 表单中 max_file_size 选项指定的值。
upload_err_partial
值:3; 文件只有部分被上传。
upload_err_no_file
值:4; 没有文件被上传。
值:5; 上传文件大小为0.
php代码
<?php
$mkdir_file_dir = mkdir('./img/'.$_post['title'],0777); //上传文件的时候就开始创建一个图片相关的目录
$tmp_file_name = $_files['file']['tmp_name']; //上传成功之后取的临时文件名
$file_name = $_files['file']['name']; //原始的文件名
$file_dir = './img/'.$_post['title'].'/'; //把创建的一个目录赋值给你一个变量作为最终的保存目录
if(is_dir($file_dir))
{
move_uploaded_file($tmp_file_name,$file_dir.$file_name); //开始移动文件
}
?>
html代码
<html>
<head>
<title>
my is upfile app!!
</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>
<body>
<form enctype="multipart/form-data" method="post" action="upfile_add.php">
标题: <input type="text" name="title" />
上传文件: <input type="file" name="file" />
<input type="submit" vlaue="提交" />
</form>
</body>
</html>
非常重要的一点是:文件通过post提交后是保存在c:windowstemp临时文件夹中通过$_files["photo"]["tmp_name"],我们可以轻松获得上传的临时文件,将它保存到我们指定的路径中 下面是解决方案move_uploaded_file($_files["photo"]["tmp_name"],$path)
<?php教程
$oimg = "test.jpg";//original image name
$classes = array('translation','autoheight','autowidth','stretch');//give classes for the new creating images' size which are defined in the specified ini file
$suffix = 'jpg';//the new image's suffix
$inifile = 'image.ini.php';$size = getimagesize($oimg);
$x = $size[0]/$size[1];
$name = explode('.',$oimg);if(!file_exists($inifile)) die('ini file does not exist!');
$cn = parse_ini_file($inifile,true);//parse the class style image size from ini file
foreach($classes as $class){
foreach($cn as $k=>$v){
if($k==$class){
if($v['width'] && $v['height']){
$thumbwidth = $v['width'];
$thumbheight = $v['height'];
}elseif($v['width']){
$thumbwidth = $v['width'];
$thumbheight = round($thumbwidth/$x);
}elseif($v['height']){
$thumbheight = $v['height'];
$thumbwidth = round($thumbheight*$x);
}else{
$thumbwidth = $size[0];
$thumbheight = $size[1];
}
break;
}
}
if(!isset($thumbheight) && !isset($thumbwidth)) die('ini file settings error!');$nimg = $name[0].'_'.$class.'.'.$suffix;//new image file name
$source = imagecreatefromjpeg($oimg);
$thumb = imagecreatetruecolor($thumbwidth, $thumbheight);
imagecopyresampled($thumb,$source,0,0,0,0,$thumbwidth,$thumbheight,$size[0],$size[1]);if($suffix=='jpg') $method = 'imagejpeg';
else $method='image'.$suffix;
$method($thumb, $nimg);
imagedestroy($thumb);//release the image source
imagedestroy($source);
}
?>
缩放图片的php代码,其中变量classes是一个数组,可以选择任意多个ini文件中指定的设置:
这是一个ini配置文件,上面的代码就要读取这个文件中的图片位置,可以多个。
<?php /*
;translate the image format using the original image size
[translation]
width=0
height=0;stretch the image to the specified size
[stretch]
width=800
height=600;zoom the image to the specified width with height auto size
[autoheight]
width=740
height=0;zoom the image to the specified height with width auto size
[autowidth]
width=0
height=380
*/ ?>
注意:ini文件使用php解释时为注释文件,什么也没有输出,这是为了安全起见而故意为之。而;则是ini文件的注释。
图片按在比较进行放大缩小,这得利用php教程 gd库的函数现实现,我们会利用到imagecreatetruecolor(),imagecopyresampled()来操作
function my_image_resize($src_file, $dst_file, $dst_width=32, $dst_height=32) {
if($dst_width <1 || $dst_height <1) {
echo "params width or height error !";
exit();
}
if(!file_exists($src_file)) {
echo $src_file . " is not exists !";
exit();
}$type=exif_imagetype($src_file);
$support_type=array(imagetype_jpeg , imagetype_png , imagetype_gif);if(!in_array($type, $support_type,true)) {
echo "this type of image does not support! only support jpg , gif or png";
exit();
}switch($type) {
case imagetype_jpeg :
$src_img=imagecreatefromjpeg($src_file);
break;
case imagetype_png :
$src_img=imagecreatefrompng($src_file);
break;
case imagetype_gif :
$src_img=imagecreatefromgif($src_file);
break;
default:
echo "load image error!";
exit();
}
$src_w=imagesx($src_img);
$src_h=imagesy($src_img);
$ratio_w=1.0 * $dst_width/$src_w;
$ratio_h=1.0 * $dst_height/$src_h;
if ($src_w<=$dst_width && $src_h<=$dst_height) {
$x = ($dst_width-$src_w)/2;
$y = ($dst_height-$src_h)/2;
$new_img=imagecreatetruecolor($dst_width,$dst_height);
imagecopy($new_img,$src_img,$x,$y,0,0,$dst_width,$dst_height);
switch($type) {
case imagetype_jpeg :
imagejpeg($new_img,$dst_file,100);
break;
case imagetype_png :
imagepng($new_img,$dst_file);
break;
case imagetype_gif :
imagegif($new_img,$dst_file);
break;
default:
break;
}
} else {
$dstwh = $dst_width/$dst_height;
$srcwh = $src_w/$src_h;
if ($ratio_w <= $ratio_h) {
$zoom_w = $dst_width;
$zoom_h = $zoom_w*($src_h/$src_w);
} else {
$zoom_h = $dst_height;
$zoom_w = $zoom_h*($src_w/$src_h);
}$zoom_img=imagecreatetruecolor($zoom_w, $zoom_h);
imagecopyresampled($zoom_img,$src_img,0,0,0,0,$zoom_w,$zoom_h,$src_w,$src_h);
$new_img=imagecreatetruecolor($dst_width,$dst_height);
$x = ($dst_width-$zoom_w)/2;
$y = ($dst_height-$zoom_h)/2+1;
imagecopy($new_img,$zoom_img,$x,$y,0,0,$dst_width,$dst_height);
switch($type) {
case imagetype_jpeg :
imagejpeg($new_img,$dst_file,100);
break;
case imagetype_png :
imagepng($new_img,$dst_file);
break;
case imagetype_gif :
imagegif($new_img,$dst_file);
break;
default:
break;
}
}
}
总结,我们要生成比例生成小图就利用$dstwh = $dst_width/$dst_height;
$srcwh = $src_w/$src_h;进行判断,然后再生成。
下面提供三款生成缩代码,兼容性都相当的不错,也可以自定高度与宽度哦。
function imageresize($srcfile,$tow,$toh,$tofile="")
{
if($tofile==""){ $tofile = $srcfile; }
$info = "";
$data = getimagesize($srcfile,$info);
switch ($data[2])
{
case 1:
if(!function_exists("imagecreatefromgif")){
echo "你的gd库不能使用gif格式的图片,请使用jpeg或png格式!<a href='网页特效:go(-1);'>返回</a>";
exit();
}
$im = imagecreatefromgif($srcfile);
break;
case 2:
if(!function_exists("imagecreatefromjpeg")){
echo "你的gd库不能使用jpeg格式的图片,请使用其它格式的图片!<a href='javascript:go(-1);'>返回</a>";
exit();
}
$im = imagecreatefromjpeg($srcfile);
break;
case 3:
$im = imagecreatefrompng($srcfile);
break;
}
$srcw=imagesx($im);
$srch=imagesy($im);
$towh=$tow/$toh;
$srcwh=$srcw/$srch;
if($towh<=$srcwh){
$ftow=$tow;
$ftoh=$ftow*($srch/$srcw);
}
else{
$ftoh=$toh;
$ftow=$ftoh*($srcw/$srch);
}
if($srcw>$tow||$srch>$toh)
{
if(function_exists("imagecreatetruecolor")){
@$ni = imagecreatetruecolor($ftow,$ftoh);
if($ni) imagecopyresampled($ni,$im,0,0,0,0,$ftow,$ftoh,$srcw,$srch);
else{
$ni=imagecreate($ftow,$ftoh);
imagecopyresized($ni,$im,0,0,0,0,$ftow,$ftoh,$srcw,$srch);
}
}else{
$ni=imagecreate($ftow,$ftoh);
imagecopyresized($ni,$im,0,0,0,0,$ftow,$ftoh,$srcw,$srch);
}
if(function_exists('imagejpeg')) imagejpeg($ni,$tofile);
else imagepng($ni,$tofile);
imagedestroy($ni);
}
imagedestroy($im);
}
实例代码二
<?php教程
/*构造函数-生成缩略图+水印,参数说明:
$srcfile-图片文件名,
$dstfile-另存文件名,
$markwords-水印文字,
$markimage-水印图片,
$dstw-图片保存宽度,
$dsth-图片保存高度,
$rate-图片保存品质*/
makethumb("a.jpg","b.jpg","50","50");
function makethumb($srcfile,$dstfile,$dstw,$dsth,$rate=100,$markwords=null,$markimage=null)
{
$data = getimagesize($srcfile);
switch($data[2])
{
case 1:
$im=@imagecreatefromgif($srcfile);
break;
case 2:
$im=@imagecreatefromjpeg($srcfile);
break;
case 3:
$im=@imagecreatefrompng($srcfile);
break;
}
if(!$im) return false;
$srcw=imagesx($im);
$srch=imagesy($im);
$dstx=0;
$dsty=0;
if ($srcw*$dsth>$srch*$dstw)
{
$fdsth = round($srch*$dstw/$srcw);
$dsty = floor(($dsth-$fdsth)/2);
$fdstw = $dstw;
}
else
{
$fdstw = round($srcw*$dsth/$srch);
$dstx = floor(($dstw-$fdstw)/2);
$fdsth = $dsth;
}
$ni=imagecreatetruecolor($dstw,$dsth);
$dstx=($dstx<0)?0:$dstx;
$dsty=($dstx<0)?0:$dsty;
$dstx=($dstx>($dstw/2))?floor($dstw/2):$dstx;
$dsty=($dsty>($dsth/2))?floor($dsth/s):$dsty;
$white = imagecolorallocate($ni,255,255,255);
$black = imagecolorallocate($ni,0,0,0);
imagefilledrectangle($ni,0,0,$dstw,$dsth,$white);// 填充背景色
imagecopyresized($ni,$im,$dstx,$dsty,0,0,$fdstw,$fdsth,$srcw,$srch);
if($markwords!=null)
{
$markwords=iconv("gb2312","utf-8",$markwords);
//转换文字编码
imagettftext($ni,20,30,450,560,$black,"simhei.ttf",$markwords); //写入文字水印
//参数依次为,文字大小|偏转度|横坐标|纵坐标|文字颜色|文字类型|文字内容
}
elseif($markimage!=null)
{
$wimage_data = getimagesize($markimage);
switch($wimage_data[2])
{
case 1:
$wimage=@imagecreatefromgif($markimage);
break;
case 2:
$wimage=@imagecreatefromjpeg($markimage);
break;
case 3:
$wimage=@imagecreatefrompng($markimage);
break;
}
imagecopy($ni,$wimage,500,560,0,0,88,31); //写入图片水印,水印图片大小默认为88*31
imagedestroy($wimage);
}
imagejpeg($ni,$dstfile,$rate);
imagejpeg($ni,$srcfile,$rate);
imagedestroy($im);
imagedestroy($ni);
}
?>
支持图片上传代码
<?php
$pic_name=date("dmyhis");
// 生成图片的宽度
$pic_width=$_post['width'];// 生成图片的高度
$pic_height=$_post['length'];function resizeimage($im,$maxwidth,$maxheight,$name){
//取得当前图片大小
$width = imagesx($im);
$height = imagesy($im);
//生成缩略图的大小
if(($width > $maxwidth) || ($height > $maxheight)){
$widthratio = $maxwidth/$width;
$heightratio = $maxheight/$height;
if($widthratio < $heightratio){
$ratio = $widthratio;
}else{
$ratio = $heightratio;
}
$newwidth = $width * $ratio;
$newheight = $height * $ratio;
if(function_exists("imagecopyresampled")){
$newim = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}else{
$newim = imagecreate($newwidth, $newheight);
imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
}
imagejpeg ($newim,$name . ".jpg");
imagedestroy ($newim);
}else{
imagejpeg ($im,$name . ".jpg");
}
}if($_files['image']['size']){
//echo $_files['image']['type'];
if($_files['image']['type'] == "image/pjpeg"||$_files['image']['type'] == "image/jpg"||$_files['image']['type'] == "image/jpeg"){
$im = imagecreatefromjpeg($_files['image']['tmp_name']);
}elseif($_files['image']['type'] == "image/x-png"){
$im = imagecreatefrompng($_files['image']['tmp_name']);
}elseif($_files['image']['type'] == "image/gif"){
$im = imagecreatefromgif($_files['image']['tmp_name']);
}
if($im){
if(file_exists($pic_name.'.jpg')){
unlink($pic_name.'.jpg');
}
resizeimage($im,$pic_width,$pic_height,$pic_name);
imagedestroy ($im);
}
}
?><img src="<? echo $pic_name.'.jpg'; ?>"><br><br>
<form enctype="multipart/form-data" method="post" action="small_picture.php">
<br>
<input type="file" name="image" size="50" value="浏览"><p>
生成缩略图宽度:<input type="text" name="width" size="5"><p>
生成缩略图长度:<input type="text" name="length" size="5"><p>
<input type="submit" value="上传图片">
</form>
class securecode
{
private static $instance=null;
private $code = '';
private $fontfile;
private $validate;
private $image;
private $specialadd = 'special string for securecode';
private $codeexpire=86400;
private $codecookiename='secure_code';
/**
* 构造方法
*/
private function securecode()
{
$this->fontfile = dirname( __file__ ) . '/arial.ttf';
}
private function __construct()
{
$this->securecode();
}
public static function getinstance()
{
if (self::$instance==null)
self::$instance=new self();
return self::$instance;
}
/**
* 指定字体文件所在路径,默认为当前文件夹下arial.ttf文件
* @param $fontfile 文件路径
* @return void
*/
function loadfont($fontfile)
{
$this->fontfile = $fontfile;
}
/**
* 图片输出方法,在执行本方法前程序不应该有任何形式的输出
* @return void;
*/
function stroke()
{
$this->savecode();
self::sendheader();
imagegif( $this->validate );
imagedestroy( $this->validate );
imagedestroy( $this->image );
}
/**
* 图片保存方法
* @param $filename 保存路径
* @return void
*/
function save($filename)
{
$this->savecode();
imagegif( $this->validate , $filename );
imagedestroy( $this->validate );
imagedestroy( $this->image );
}
/**
* 验证码验证方法
* @param $input 要验证的字符串,即用户的输入内容
* @return boolean 验证结果
*/
function verify($input)
{
$input=strtolower($input);
$targetcode=$this->authcode($input);
$code=$this->getcookie();
if (empty($code)||$code!=$targetcode)
$result= false;
else
$result=true;
$_cookie[$this->codecookiename]='';
setcookie ( $this->codecookiename, '', - 1 );
return $result;
}
/**
* 图片创建方法
* @return void;
*/
function createimage()
{
$this->randcode();
$size = 30;
$width = 90;
$height = 35;
$degrees = array (
rand( 0 , 30 ), rand( 0 , 30 ), rand( 0 , 30 ), rand( 0 , 30 )
);
for ($i = 0; $i < 4; ++$i)
{
if (rand() % 2);
else $degrees[$i] = -$degrees[$i];
}
$this->image = imagecreatetruecolor( $size , $size );
$this->validate = imagecreatetruecolor( $width , $height );
$back = imagecolorallocate( $this->image , 255 , 255 , 255 );
$border = imagecolorallocate( $this->image , 0 , 0 , 0 );
imagefilledrectangle( $this->validate , 0 , 0 , $width , $height , $back );
for ($i = 0; $i < 4; ++$i)
{
$temp = self::rgbtohsv( rand( 0 , 250 ) , rand( 0 , 150 ) , rand( 0 , 250 ) );
if ($temp[2] > 60) $temp[2] = 60;
$temp = self::hsvtorgb( $temp[0] , $temp[1] , $temp[2] );
$textcolor[$i] = imagecolorallocate( $this->image , $temp[0] , $temp[1] , $temp[2] );
}
for ($i = 0; $i < 200; ++$i)
{
$randpixelcolor = imagecolorallocate( $this->validate , rand( 0 , 255 ) , rand( 0 , 255 ) , rand( 0 , 255 ) );
imagesetpixel( $this->validate , rand( 1 , 87 ) , rand( 1 , 35 ) , $randpixelcolor );
}
$temp = self::rgbtohsv( rand( 220 , 255 ) , rand( 220 , 255 ) , rand( 220 , 255 ) );
if ($temp[2] < 200) $temp[2] = 255;
$temp = self::hsvtorgb( $temp[0] , $temp[1] , $temp[2] );
$randlinecolor = imagecolorallocate( $this->image , $temp[0] , $temp[1] , $temp[2] );
self::imagelinethick( $this->validate , $textcolor[rand( 0 , 3 )] );
imagefilledrectangle( $this->image , 0 , 0 , $size , $size , $back );
putenv( 'gdfontpath=' . realpath( '.' ) );
// name the font to be used (note the lack of the .ttf extension
imagettftext( $this->image , 15 , 0 , 8 , 20 , $textcolor[0] , $this->fontfile , $this->code[0] );
$this->image = imagerotate( $this->image , $degrees[0] , $back );
imagecolortransparent( $this->image , $back );
imagecopymerge( $this->validate , $this->image , 1 , 4 , 4 , 5 , imagesx( $this->image ) - 10 , imagesy( $this->image ) - 10 , 100 );
$this->image = imagecreatetruecolor( $size , $size );
imagefilledrectangle( $this->image , 0 , 0 , $size , $size , $back );
imagettftext( $this->image , 15 , 0 , 8 , 20 , $textcolor[1] , $this->fontfile , $this->code[1] );
$this->image = imagerotate( $this->image , $degrees[1] , $back );
imagecolortransparent( $this->image , $back );
imagecopymerge( $this->validate , $this->image , 21 , 4 , 4 , 5 , imagesx( $this->image ) - 10 , imagesy( $this->image ) - 10 , 100 );
$this->image = imagecreatetruecolor( $size , $size );
imagefilledrectangle( $this->image , 0 , 0 , $size - 1 , $size - 1 , $back );
imagettftext( $this->image , 15 , 0 , 8 , 20 , $textcolor[2] , $this->fontfile , $this->code[2] );
$this->image = imagerotate( $this->image , $degrees[2] , $back );
imagecolortransparent( $this->image , $back );
imagecopymerge( $this->validate , $this->image , 41 , 4 , 4 , 5 , imagesx( $this->image ) - 10 , imagesy( $this->image ) - 10 , 100 );
$this->image = imagecreatetruecolor( $size , $size );
imagefilledrectangle( $this->image , 0 , 0 , $size - 1 , $size - 1 , $back );
imagettftext( $this->image , 15 , 0 , 8 , 20 , $textcolor[3] , $this->fontfile , $this->code[3] );
$this->image = imagerotate( $this->image , $degrees[3] , $back );
imagecolortransparent( $this->image , $back );
imagecopymerge( $this->validate , $this->image , 61 , 4 , 4 , 5 , imagesx( $this->image ) - 10 , imagesy( $this->image ) - 10 , 100 );
imagerectangle( $this->validate , 0 , 0 , $width - 1 , $height - 1 , $border );
}
/**
* 获取随机生成的验证码
* @return string 随机验证码,返回的验证码不进行任何处理
*/
function getcode()
{
return $this->code;
}
/**
* 生成随机码方法
* @return void;
*/
protected function randcode()
{
$alphastr = 'abcdefghijklmnpqrstuvwxyz123456789';
$randstr = array (
$alphastr{rand( 0 , 33 )}, $alphastr{rand( 0 , 33 )}, $alphastr{rand( 0 , 33 )}, $alphastr{rand( 0 , 33 )}
);
$this->code = strtolower( $randstr[0] . $randstr[1] . $randstr[2] . $randstr[3] );
}
/**
* rgb色到hsv色转变方法
* @param $r
* @param $g
* @param $b
* @return array hsv数组
*/
protected static function rgbtohsv($r, $g, $b)
{
$tmp = min( $r , $g );
$min = min( $tmp , $b );
$tmp = max( $r , $g );
$max = max( $tmp , $b );
$v = $max;
$delta = $max - $min;
if ($max != 0) $s = $delta / $max; // s
else
{
$s = 0;
//$h = undefinedcolor;
return;
}
if ($r == $max) $h = ($g - $b) / $delta; // between yellow & magenta
else if ($g == $max) $h = 2 + ($b - $r) / $delta; // between cyan & yellow
else $h = 4 + ($r - $g) / $delta; // between magenta & cyan
$h *= 60; // degrees
if ($h < 0) $h += 360;
return array (
$h, $s, $v
);
}
/**
* 同上一方法功能相反
* @param $h
* @param $s
* @param $v
* @return array rgb数组
*/
protected static function hsvtorgb($h, $s, $v)
{
if ($s == 0)
{
// achromatic (grey)
$r = $g = $b = $v;
return;
}
$h /= 60; // sector 0 to 5
$i = floor( $h );
$f = $h - $i; // factorial part of h
$p = $v * (1 - $s);
$q = $v * (1 - $s * $f);
$t = $v * (1 - $s * (1 - $f));
switch ($i)
{
case 0 :
$r = $v;
$g = $t;
$b = $p;
break;
case 1 :
$r = $q;
$g = $v;
$b = $p;
break;
case 2 :
$r = $p;
$g = $v;
$b = $t;
break;
case 3 :
$r = $p;
$g = $q;
$b = $v;
break;
case 4 :
$r = $t;
$g = $p;
$b = $v;
break;
default : // case 5:
$r = $v;
$g = $p;
$b = $q;
break;
}
return array (
$r, $g, $b
);
}
/**
* 使用cookie保存验证码的方法
* @return void
*/
protected function savecode()
{
$code = $this->authcode($this->code);
$this->setcookie($code);
}
/**
* 验证码cookie值获取方法
* @return string cookie值
*/
protected function getcookie()
{
if (empty( $_cookie[$this->codecookiename] ))
{
return '';
}
else
{
return addslashes($_cookie[$this->codecookiename]);
}
}
/**
* 验证码cookie创建方法
* @param string $code 要保存的验证码
* @return void
*/
protected function setcookie($code)
{
$expire = $this->codeexpire > 0 ? $this->codeexpire + time() : 0;
setcookie( $this->codecookiename , $code, $expire );
}
/**
* 验证码加密方法
* @param string $code 要加密的随机码
* @return mixed 执行结果
*/
protected function authcode($code)
{
return md5($code.$this->specialadd);
}
/**
* 干扰线生成方法
* @param resource $image 图片资源句柄
* @param string $color 干扰线颜色
*/
protected static function imagelinethick($image, $color)
{
$k = rand( 5 , 20 );
for ($px = 0; $px < 400; $px = $px + 1)
{
$y = $k * sin( 0.1 * ($px) ); //$y=200+10*sin(0.1*($px-200));
for ($i = 0; $i < 2; $i++)
{
imagesetpixel( $image , $px , $y + 10 + $i , $color );
}
}
}
/**
* http标头设置方法
* @return void
*/
protected static function sendheader()
{
header( "pragma: no-cache" );
header( "cache-control: max-age=1, s-maxage=1, no-cache, must-revalidate" );
header( 'content-type: image/gif' );
}
}
http://down.111cn.net/down/code/php/qitayuanma/2010/1220/22330.html
相关文章
使用PHP+JavaScript将HTML页面转换为图片的实例分享
这篇文章主要介绍了使用PHP+JavaScript将HTML元素转换为图片的实例分享,文后结果的截图只能体现出替换的字体,也不能说将静态页面转为图片可以加快加载,只是这种做法比较interesting XD需要的朋友可以参考下...2016-04-19- php如何实现抓取网页图片,相较于手动的粘贴复制,使用小程序要方便快捷多了,喜欢编程的人总会喜欢制作一些简单有用的小软件,最近就参考了网上一个php抓取图片代码,封装了一个php远程抓取图片的类,测试了一下,效果还不错分享...2015-10-30
- 这篇文章主要介绍了C#从数据库读取图片并保存的方法,帮助大家更好的理解和使用c#,感兴趣的朋友可以了解下...2021-01-16
- 今天小编在这里就来给各位Photoshop的这一款软件的使用者们来说说把古装美女图片转为细腻的工笔画效果的制作教程,各位想知道方法的使用者们,那么下面就快来跟着小编一...2016-09-14
- 这篇文章主要介绍了Python 图片转数组,二进制互转操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-03-09
- 下面小编就为大家带来一篇利用JS实现点击按钮后图片自动切换的简单方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2016-10-25
- 有一种方法,可以不打开网站而直接查看到这个网站的源代码.. 这样可以有效地防止误入恶意网站... 在浏览器地址栏输入: view-source:http://...2016-09-20
- <?php require('path.inc.php'); header('content-Type: text/html; charset=utf-8'); $borough_id = intval($_GET['id']); if(!$borough_id){ echo ' ...2016-11-25
jquery左右滚动焦点图banner图片鼠标经过显示上下页按钮
jquery左右滚动焦点图banner图片鼠标经过显示上下页按钮...2013-10-13- 本文实例讲述了JS基于Mootools实现的个性菜单效果代码。分享给大家供大家参考,具体如下:这里演示基于Mootools做的带动画的垂直型菜单,是一个初学者写的,用来学习Mootools的使用有帮助,下载时请注意要将外部引用的mootools...2015-10-23
- 这篇文章主要为大家详细介绍了js实现上传图片及时预览的相关资料,具有一定的参考价值,感兴趣的朋友可以参考一下...2016-05-09
- 本文实例讲述了JS+CSS实现分类动态选择及移动功能效果代码。分享给大家供大家参考,具体如下:这是一个类似选项卡功能的选择插件,与普通的TAb区别是加入了动画效果,多用于商品类网站,用作商品分类功能,不过其它网站也可以用,...2015-10-21
- 本文实例讲述了JS实现自定义简单网页软键盘效果。分享给大家供大家参考,具体如下:这是一款自定义的简单点的网页软键盘,没有使用任何控件,仅是为了练习JavaScript编写水平,安全性方面没有过多考虑,有顾虑的可以不用,目的是学...2015-11-08
- php 取除连续空格与换行代码,这些我们都用到str_replace与正则函数 第一种: $content=str_replace("n","",$content); echo $content; 第二种: $content=preg_replac...2016-11-25
- php简单用户登陆程序代码 这些教程很对初学者来讲是很有用的哦,这款就下面这一点点代码了哦。 <center> <p> </p> <p> </p> <form name="form1...2016-11-25
- Photoshop的这一款软件小编相信很多的人都已经是使用过了吧,那么今天小编在这里就给大家带来了用Photoshop软件制作枪战电影海报的教程,想知道制作步骤的玩家们,那么下面...2016-09-14
- 公司一些wordpress网站由于下载的插件存在恶意代码,导致整个服务器所有网站PHP文件都存在恶意代码,就写了个简单的脚本清除。恶意代码示例...2015-10-23
- 本文实例讲述了JS实现双击屏幕滚动效果代码。分享给大家供大家参考,具体如下:这里演示双击滚屏效果代码的实现方法,不知道有觉得有用处的没,现在网上还有很多还在用这个特效的呢,代码分享给大家吧。运行效果截图如下:在线演...2015-10-30
- 其实挺简单的就是if(navigator.userAgent.indexOf('UCBrowser') > -1) {alert("uc浏览器");}else{//不是uc浏览器执行的操作}如果想测试某个浏览器的特征可以通过如下方法获取JS获取浏览器信息 浏览器代码名称:navigator...2015-11-08
- 一、日期减去天数等于第二个日期function cc(dd,dadd){//可以加上错误处理var a = new Date(dd)a = a.valueOf()a = a - dadd * 24 * 60 * 60 * 1000a = new Date(a)alert(a.getFullYear() + "年" + (a.getMonth() +...2015-11-08