欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php+flash+jQuery多圖片上傳源碼分享

 更新時(shí)間:2020年07月27日 15:17:21   投稿:lijiao  
這篇文章主要為大家詳細(xì)介紹了php+flash+jQuery多圖片上傳實(shí)現(xiàn)源碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

flash+php多圖片上傳的源碼,測(cè)試成功,一個(gè)經(jīng)典的上傳源碼,為什么要用flash作為上傳的組件呢,其實(shí)這里不僅僅是flash,另加了jquery的技術(shù),這樣做的目的是為了更好更方便的管理圖片,使用過(guò)QQ空間進(jìn)行上傳圖片的童鞋都知道,QQ空間的上傳體驗(yàn)度很好,而且管理我們上傳的圖片非常的方便,使用的技術(shù)基本上就是flash與jquery技術(shù)了。

flash+jquery是作為前端圖片上傳展示的,還需要與php的結(jié)合才能將圖片上傳到指定的目標(biāo),這里的php一共有兩個(gè)文件,一個(gè)upload.php 是上傳的核心代碼,index.php 便是整合 flash+php+jquery 技術(shù)的結(jié)合,將提交上來(lái)的圖片上傳到目錄 upload 下面,另外還有一個(gè)文件夾 images,這里面便是調(diào)用的 upload.swf flash文件和jquery.js文件了,技術(shù)已經(jīng)實(shí)現(xiàn)了,剩下便是怎樣跟數(shù)據(jù)庫(kù)進(jìn)行整合就很簡(jiǎn)單了,這里不再詳解了。

效果圖:

關(guān)鍵代碼:

upload.php

<?php

 $uploaddir = 'upload/';
 $filename = date("Ymdhis").rand(100,999);
 $uploadfile = $uploaddir . $filename.substr($_FILES['Filedata']["name"],strrpos($_FILES['Filedata']["name"],"."));
 $temploadfile = $_FILES['Filedata']['tmp_name'];
 move_uploaded_file($temploadfile , $uploadfile);

 //返回?cái)?shù)據(jù) 在頁(yè)面上js做處理
 $filedata = array(
 'result' => 'true',
 'name' => $_FILES['Filedata']["name"],
 'filepath' => $uploadfile,
 );
 echo json_encode($filedata);
 exit;

index.php

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>swfupload</title>
<script src="images/jquery.js" type="text/javascript"></script>
<script>
 /*上傳錯(cuò)誤信息提示*/
 function showmessage(message){alert(message);}
 /*顯示文件名稱*/
 function setfilename(ID,filename){
 ID = replaceStr(ID);
 var htmls = '<li id="'+ID+'"><p>'+filename+'</p><p class="load">0%</p></li>';
 $("#uploadPut").append(htmls);
 }
 /*顯示上傳進(jìn)度*/
 function setfileload(ID,load){
 ID = replaceStr(ID);
 $("#"+ID+" .load").html(load);
 }
 /*返回服務(wù)上傳的數(shù)據(jù)*/
 function setfilepath(ID,data){
 ID = replaceStr(ID);
 var s = eval('('+data+')');
 if(s.result=="true"){
 $("#"+ID).html("<img id='"+s.id+"' src='"+s.filepath+"'/><br/>"+s.name);
 }else{
 $("#"+ID).html(s.name+"上傳失敗");
 }
 }
 /*替換特殊字符*/
 function replaceStr(ID){
 var reg = new RegExp("[=,/,\,?,%,#,&,(,),!,+,-,},{,:,>,<]","g"); //創(chuàng)建正則RegExp對(duì)象
 var ID = ID.replace(reg,"");
 return ID;
 }
</script>
</head>
<style>
 .main{ width:610px; height:0px auto; border:1px solid #e1e1e1; font-size:12px; padding:10px;}
 .main p{ line-height:10px; width:500px; float:right; text-indent:20px;}
 .uploadPut{ width:100%; clear:both;}
 ul,li{ margin:0px; padding:0px; list-style:none}
 .uploadPut li{width:120px; padding:10px; text-align:center; border:1px solid #ccc; overflow:hidden; background-color:#e1e1e1; line-height:25px; float:left; margin:5px}
 .uploadPut img{ width:120px; height:90px;}
</style>
<body>
 <div class="main"> 
 <?php
 //獲取項(xiàng)目跟路徑
 $baseURL = 'http://' . $_SERVER ['SERVER_NAME'] . (($_SERVER ['SERVER_PORT'] == 80) ? '' : ':' . $_SERVER ['SERVER_PORT']) . ((($path = str_ireplace('\\', '/', dirname ( $_SERVER ['SCRIPT_NAME'] ))) == '/') ? '' : $path);
 
 
 //設(shè)置swfupload參數(shù)
 $flashvars = 'uploadURL=' . urlencode($baseURL . '/upload.php'); #上傳提交地址
 $flashvars.= '&buttonImageURL=' . urlencode($baseURL . '/images/upload.png'); #按鈕背景圖片
 $flashvars.= '&btnWidth=95';    #按鈕寬度
 $flashvars.= '&btnHeight=35';    #按鈕高度
 $flashvars.= '&fileNumber=20';    #每次最多上傳20個(gè)文件
 $flashvars.= '&fileSize=200';   #單個(gè)文件上傳大小為20M
 $flashvars.= '&bgColor=#ffffff';    #背景顏色
 $flashvars.= '&fileTypesDescription=Images';   #選擇文件類型
 $flashvars.= '&fileType=*.jpg;*.png;*.gif;*.jpeg';   #選擇文件后綴名 
 
 ?>
 <object style="float: left;" width="95" height="35" data="images/upload.swf" type="application/x-shockwave-flash">
 <param value="transparent" name="wmode">
 <param value="images/upload.swf" name="movie">
 <param value="high" name="quality">
 <param value="false" name="menu">
 <param value="always" name="allowScriptAccess">
 <param value="<?php echo $flashvars;?>" name="flashvars">
 </object>
 <p>允許上傳格式 JPG, GIF, JEPG, PNG ,每個(gè)文件不超過(guò)20MB,一次可上傳多20張!</p>
 
 <div class="uploadPut">
 <ul id="uploadPut">
 
 </ul>
 <div style="clear: both;"></div>
 </div>
 
 </div>
</body>
</html>

其實(shí)這種組合的上傳技術(shù)在許多大型的網(wǎng)站上面都有,更多的是應(yīng)用在圖片的管理上面,比如 51 空間的圖片管理,基本功能都是類似的,重要的一定要學(xué)習(xí)一下 flash 與 php 之間的通信技術(shù),在大型的開(kāi)發(fā)中,這種技術(shù)會(huì)經(jīng)常出現(xiàn)的。

源碼下載:http://xiazai.jb51.net/201607/yuanma/php+flash(jb51.net).rar

更多精彩內(nèi)容,請(qǐng)點(diǎn)擊《jQuery上傳操作匯總》,進(jìn)行深入學(xué)習(xí)和研究。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論