没有合适的资源?快使用搜索试试~ 我知道了~
php图片上传存储源码并且可以预览
3 下载量 108 浏览量
2020-12-18
18:55:40
上传
评论 2
收藏 53KB PDF 举报
温馨提示
试读
3页
复制代码 代码如下: <?php header(“content-Type: text/html; charset=gb2312”); $uptypes=array(‘image/jpg’, //上传文件类型列表 ‘image/jpeg’, ‘image/png’, ‘image/pjpeg’, ‘image/gif’, ‘image/bmp’, ‘application/x-shockwave-flash’, ‘image/x-png’, ‘application/msword’, ‘audio/x-ms-wma’, ‘audio/mp3’, ‘application/vnd.rn-real
资源详情
资源评论
资源推荐
php图片上传存储源码并且可以预览图片上传存储源码并且可以预览
复制代码 代码如下:
<?php
header(“content-Type: text/html; charset=gb2312”);
$uptypes=array(‘image/jpg’, //上传文件类型列表
‘image/jpeg’,
‘image/png’,
‘image/pjpeg’,
‘image/gif’,
‘image/bmp’,
‘application/x-shockwave-flash’,
‘image/x-png’,
‘application/msword’,
‘audio/x-ms-wma’,
‘audio/mp3’,
‘application/vnd.rn-realmedia’,
‘application/x-zip-compressed’,
‘application/octet-stream’);
$max_file_size=10000000; //上传文件大小限制, 单位BYTE
$path_parts=pathinfo($_SERVER[‘PHP_SELF’]); //取得当前路径
$destination_folder=”up/”; //上传文件路径
$watermark=0; //是否附加水印(1为加水印,0为不加水印);
$watertype=1; //水印类型(1为文字,2为图片)
$waterposition=2; //水印位置(1为左下角,2为右下角,3为左上角,4为右上角,5为居中);
$waterstring=”www.yinao.tk”; //水印字符串
$waterimg=”xplore.gif”; //水印图片
$imgpreview=1; //是否生成预览图(1为生成,0为不生成);
$imgpreviewsize=1/1; //缩略图比例
?>
<html xmlns=”undefined”>
<head>
<title>图片上传储存</title>
<LINK rel=”Bookmark” href=”http://www.yinao.tk/ico.ico” >
<LINK rel=”Shortcut Icon” href=”http://www.yinao.tk/ico.ico” />
<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″>
<meta name=”description” content=”亿脑网盘_免费网络无限大图片上传储存” />
<style type=”text/css”>
body,td{font-family:tahoma,verdana,arial;font-size:11px;line-height:15px;background-color:white;color:#666666;
strong{font-size:12px;}
a:link{color:#0066CC;}
a:hover{color:#FF6600;}
a:visited{color:#003366;}
a:active{color:#9DCC00;}
a{TEXT-DECORATION:none}
td.irows{height:20px;background:url(“index.php?i=dots”) repeat-x bottom}
</style>
</head>
<script type=”text/javascript”>function oCopy(obj){obj.select();js=obj.createTextRange();js.execCommand(“Copy”);};function sendtof(url)
{window.clipboardData.setData(‘Text’,url);alert(‘复制地址成功,粘贴给你好友一起分享。’);};function select_format(){var
on=document.getElementById(‘fmt’).checked;document.getElementById(‘site’).style.display=on?’none’:”;document.getElementById(‘sited’).style.display=!on?’none’:”;};var
flag=false;function DrawImage(ImgD){var image=new Image();image.src=ImgD.src;if(image.width>0&&image.height>0){flag=true;if(image.width/image.height>=120/80)
{if(image.width>120){ImgD.width=120;ImgD.height=(image.height*120)/image.width;}else
{ImgD.width=image.width;ImgD.height=image.height;};ImgD.alt=image.width+”×”+image.height;}else {if(image.height>80){ImgD.height=80;ImgD.width=
(image.width*80)/image.height;}else {ImgD.width=image.width;ImgD.height=image.height;};ImgD.alt=image.width+”×”+image.height;}};};function FileChange(Value)
{flag=false;document.all.uploadimage.width=10;document.all.uploadimage.height=10;document.all.uploadimage.alt=””;document.all.uploadimage.src=Value;};</script>
<body bgcolor=”#FFFFFF”>
<center>
<form enctype=”multipart/form-data” method=”post” name=”upform”>
<table border=”1″ width=”55%” id=”table1″ cellspacing=0>
<tr>
<td colspan=”2″><p align=”center”>最大文件限制1M </td>
</tr>
<tr>
<td width=”10%”><div style=”width:120px; height:80px;overflow:hidden;text-align: center;” ><IMG id=uploadimage height=0 width=0 src=””
onload=”javascript:DrawImage(this);” ></div></td>
<td width=”71%”><div style=”width:361px; height:80px;overflow:hidden;text-align: center;padding:30px; ” >
<input style=”width:208;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff; height:18″ size=”17″ name=upfile type=file
onchange=”javascript:FileChange(this.value);”>
<input type=”submit” value=”上传” style=”width:60;border:1 solid #9a9999; font-size:9pt; background-color:#ffffff; height:18″ size=”17″></td>
</tr>
</table>
允许上传的文件类型为:jpg|jpeg|gif|bmp|png|swf|mp3|wma|zip|rar|doc</form>
<?php
if ($_SERVER[‘REQUEST_METHOD’] == ‘POST’)
{
if (!is_uploaded_file($_FILES[“upfile”][tmp_name]))
//是否存在文件
{
echo “<font color=’red’>文件不存在!</font>”;
exit;
}
$file = $_FILES[“upfile”];
if($max_file_size < $file[“size”])
//检查文件大小
{
echo “<font color=’red’>文件太大!</font>”;
exit;
}
if(!in_array($file[“type”], $uptypes))
//检查文件类型
weixin_38700430
- 粉丝: 3
- 资源: 915
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0