分类分类
更新时间:2026-02-18 19:58:01作者:sa
下面来为你免费提供一款php 图片上传代码,如果你正在找文件上传的图片代码就进来看看吧,这是一款只支持jpg,gif,png,swf文件上传的php实例代码.
PHP实例代码如下:
代码如下:
<?php
if($_FILES['file']){
// 上传设置
$maxsize=10002400; //最大允许上传的文件大小
$alltype=array(".jpg",".JPG",".GIF",".gif",".png",".swf"); //所有允许上传的文件类型
$imgtype=array(".jpg",".JPG",".GIF",".gif",".png",".swf");
//图片类型
// 判断文件大小
if($_FILES['file']['size']>$maxsize) {
echo "您上传的资料大于10000K";
exit;
}
// 判断文件类型
$type=strstr($_FILES['file']['name'],".");
if(!in_array($type,$alltype)){
echo "不允许上传该类型的文件";
exit;
}
$updir="uploaddir";
$time=date("Ymd-His",time());
$fn=$time.$type;
$destination=$updir."/".$fn;
if(@move_uploaded_file($_FILES['file']['tmp_name'], $destination)){
@chmod($destination, 0777);
$fileurl=$updir."/".$destination;
$fileurl="".$destination;
}else{
echo "上传失败!";
echo "<script>location.href=history.back()</script>";
}
// ----------------------------------------------------------------------------------------------//
}//开源代码phpfensi.com
if($back=="no"):
echo "ok";
exit;
endif;
?>
html代码如下:
代码如下:
<html>
<head>
<title>添加图片</title>
<script language="JavaScript">
function isnull()
{
if(document.all.fileurl.value!="")insert();
}
function insert()
{
images='<img style="cursor:hand" src="'+insertpic.fileurl.value+'">';
edit = window.opener.document.mode_iframe.document.selection.createRange();
edit.pasteHTML (images);
window.close();
}
</script>
<style>
BODY { FONT-SIZE: 12px; FONT-FAMILY: tahoma,宋体;}
TABLE { empty-cells: show;}
TD { FONT-SIZE: 12px; COLOR: #000000; FONT-FAMILY: tahoma,宋体;margin: 5}
</style>
</head>
<body leftMargin=12 topMargin=12 marginwidth=2 marginheight=2 bgcolor='#D6D3CE' style="border:0px" onload=isnull()>
<form action=<?=$_SERVER['PHP_SELF']?> name=insertpic enctype=multipart/form-data method=post>
<table>
<tr>
<td></td>
<td width=60>上传图片</td>
<td>
<input class=mmcinb type="file" name="file" size="14">
<input class=mmcinb type="submit" value="上传"></td>
</tr>
<tr>
<td></td>
<td>图片URL</td>
<td><input class=mmcinb type="text" name="fileurl" value="<?=$fileurl?>" size="26">
<button onclick=insert()>插入</button></td>
</tr>
<tr>
<td></td>
<td colspan=2 align=left><font color=red>可以直接输入图片的URL,点击插入即可(不能有中文)<br>
</font></td>
</tr>
</table>
</form>
<script language="JavaScript">
<!--
//picurl.focus();
//-->
</script>
</body>
</html>
相关
归墟战纪策略游戏262.92 MBv3.95802026-02-14
下载爆裂老奶策略游戏209.43 MBv1.0.112026-02-14
下载超能下蛋鸭策略游戏395.4 MBv1.2.82026-02-14
下载你好盒子实用工具12.1 MBv2.2.852026-02-14
下载我在峡谷当牛马休闲益智87.95 MBv0.7.12026-02-14
下载抽卡监狱2策略游戏190.75 MBv1.4.92026-02-14
下载Campus社交通讯94.36 MBv1.19.02026-02-14
下载冒险传奇角色扮演141.73 Mv9991.12026-02-14
下载心动次元app社交通讯43.96 Mv1.0.1.32026-02-14
下载致亲爱的我角色扮演1.63Gv1.02026-02-14
下载狼伴侣游戏手机版冒险游戏155.6 Mv1.02026-02-14
下载Loclike社交通讯169.08 Mv2.2.112026-02-14
下载










