国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

php 圖片上傳代碼例子

2024-04-25 20:37:07
字體:
來源:轉載
供稿:網友

下面來為你免費提供一款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>

 

 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 普陀区| 大连市| 滦南县| 平湖市| 烟台市| 彭水| 岳池县| 大荔县| 和平县| 临城县| 新泰市| 河津市| 广河县| 商城县| 庆元县| 南平市| 香港 | 成安县| 广灵县| 吉林市| 绵阳市| 阿荣旗| 石首市| 台中县| 来凤县| 松原市| 天气| 永吉县| 永昌县| 宜良县| 威海市| 苗栗县| 达尔| 平乐县| 睢宁县| 喀什市| 吉林市| 福安市| 天台县| 建宁县| 荔浦县|