<p id="es3zh"></p>

      <rt id="es3zh"><optgroup id="es3zh"></optgroup></rt>
      \n
      \n <?php\n \/\/獲取項目跟路徑\n $baseURL = 'http:\/\/' . $_SERVER ['SERVER_NAME'] . (($_SERVER ['SERVER_PORT'] == 80) ? '' : ':' . $_SERVER ['SERVER_PORT']) . ((($path = str_ireplace('\\\\', '\/', dirname ( $_SERVER ['SCRIPT_NAME'] ))) == '\/') ? '' : $path);\n \n \n \/\/設(shè)置swfupload參數(shù)\n $flashvars = 'uploadURL=' . urlencode($baseURL . '\/upload.php'); #上傳提交地址\n $flashvars.= '&buttonImageURL=' . urlencode($baseURL . '\/images\/upload.png'); #按鈕背景圖片\n $flashvars.= '&btnWidth=95'; #按鈕寬度\n $flashvars.= '&btnHeight=35'; #按鈕高度\n $flashvars.= '&fileNumber=20'; #每次最多上傳20個文件\n $flashvars.= '&fileSize=200'; #單個文件上傳大小為20M\n $flashvars.= '&bgColor=#ffffff'; #背景顏色\n $flashvars.= '&fileTypesDescription=Images'; #選擇文件類型\n $flashvars.= '&fileType=*.jpg;*.png;*.gif;*.jpeg'; #選擇文件后綴名 \n \n ?>\n \n \n \n \n \n \n \" name=\"flashvars\">\n <\/object>\n

      允許上傳格式 JPG, GIF, JEPG, PNG ,每個文件不超過20MB,一次可上傳多20張!<\/p>\n \n

      \n
        \n \n <\/ul>\n
        <\/div>\n <\/div>\n \n <\/div>\n<\/body>\n<\/html>\n\n<\/pre>\n<\/div>\n

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

        源碼下載:http:\/\/xiazai.php.net\/201607\/yuanma\/php+flash(php.net).rar<\/p>\n

        以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。<\/p>\n\n"}

        国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

        Home Backend Development PHP Tutorial php+flash+jQuery multiple image upload source code sharing_php example

        php+flash+jQuery multiple image upload source code sharing_php example

        Aug 04, 2016 am 08:56 AM
        php image upload

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

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

        效果圖:

        關(guān)鍵代碼:

        upload.php

        <&#63;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);
        
          //返回數(shù)據(jù) 在頁面上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>
         /*上傳錯誤信息提示*/
         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("[=,/,\,&#63;,%,#,&,(,),!,+,-,},{,:,>,<]","g"); //創(chuàng)建正則RegExp對象
          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"> 
         <&#63;php
          //獲取項目跟路徑
         $baseURL = 'http://' . $_SERVER ['SERVER_NAME'] . (($_SERVER ['SERVER_PORT'] == 80) &#63; '' : ':' . $_SERVER ['SERVER_PORT']) . ((($path = str_ireplace('\\', '/', dirname ( $_SERVER ['SCRIPT_NAME'] ))) == '/') &#63; '' : $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個文件
           $flashvars.= '&fileSize=200';            #單個文件上傳大小為20M
           $flashvars.= '&bgColor=#ffffff';               #背景顏色
           $flashvars.= '&fileTypesDescription=Images';            #選擇文件類型
           $flashvars.= '&fileType=*.jpg;*.png;*.gif;*.jpeg';           #選擇文件后綴名 
         
          &#63;>
            <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="<&#63;php echo $flashvars;&#63;>" name="flashvars">
            </object>
            <p>允許上傳格式 JPG, GIF, JEPG, PNG ,每個文件不超過20MB,一次可上傳多20張!</p>
            
          <div class="uploadPut">
           <ul id="uploadPut">
           
           </ul>
           <div style="clear: both;"></div>
          </div>
          
         </div>
        </body>
        </html>
        
        

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

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

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

        Statement of this Website
        The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

        Hot AI Tools

        Undress AI Tool

        Undress AI Tool

        Undress images for free

        Undresser.AI Undress

        Undresser.AI Undress

        AI-powered app for creating realistic nude photos

        AI Clothes Remover

        AI Clothes Remover

        Online AI tool for removing clothes from photos.

        Clothoff.io

        Clothoff.io

        AI clothes remover

        Video Face Swap

        Video Face Swap

        Swap faces in any video effortlessly with our completely free AI face swap tool!

        Hot Tools

        Notepad++7.3.1

        Notepad++7.3.1

        Easy-to-use and free code editor

        SublimeText3 Chinese version

        SublimeText3 Chinese version

        Chinese version, very easy to use

        Zend Studio 13.0.1

        Zend Studio 13.0.1

        Powerful PHP integrated development environment

        Dreamweaver CS6

        Dreamweaver CS6

        Visual web development tools

        SublimeText3 Mac version

        SublimeText3 Mac version

        God-level code editing software (SublimeText3)

        Hot Topics

        PHP Tutorial
        1502
        276
        PHP Variable Scope Explained PHP Variable Scope Explained Jul 17, 2025 am 04:16 AM

        Common problems and solutions for PHP variable scope include: 1. The global variable cannot be accessed within the function, and it needs to be passed in using the global keyword or parameter; 2. The static variable is declared with static, and it is only initialized once and the value is maintained between multiple calls; 3. Hyperglobal variables such as $_GET and $_POST can be used directly in any scope, but you need to pay attention to safe filtering; 4. Anonymous functions need to introduce parent scope variables through the use keyword, and when modifying external variables, you need to pass a reference. Mastering these rules can help avoid errors and improve code stability.

        How to handle File Uploads securely in PHP? How to handle File Uploads securely in PHP? Jul 08, 2025 am 02:37 AM

        To safely handle PHP file uploads, you need to verify the source and type, control the file name and path, set server restrictions, and process media files twice. 1. Verify the upload source to prevent CSRF through token and detect the real MIME type through finfo_file using whitelist control; 2. Rename the file to a random string and determine the extension to store it in a non-Web directory according to the detection type; 3. PHP configuration limits the upload size and temporary directory Nginx/Apache prohibits access to the upload directory; 4. The GD library resaves the pictures to clear potential malicious data.

        Commenting Out Code in PHP Commenting Out Code in PHP Jul 18, 2025 am 04:57 AM

        There are three common methods for PHP comment code: 1. Use // or # to block one line of code, and it is recommended to use //; 2. Use /.../ to wrap code blocks with multiple lines, which cannot be nested but can be crossed; 3. Combination skills comments such as using /if(){}/ to control logic blocks, or to improve efficiency with editor shortcut keys, you should pay attention to closing symbols and avoid nesting when using them.

        Tips for Writing PHP Comments Tips for Writing PHP Comments Jul 18, 2025 am 04:51 AM

        The key to writing PHP comments is to clarify the purpose and specifications. Comments should explain "why" rather than "what was done", avoiding redundancy or too simplicity. 1. Use a unified format, such as docblock (/*/) for class and method descriptions to improve readability and tool compatibility; 2. Emphasize the reasons behind the logic, such as why JS jumps need to be output manually; 3. Add an overview description before complex code, describe the process in steps, and help understand the overall idea; 4. Use TODO and FIXME rationally to mark to-do items and problems to facilitate subsequent tracking and collaboration. Good annotations can reduce communication costs and improve code maintenance efficiency.

        How Do Generators Work in PHP? How Do Generators Work in PHP? Jul 11, 2025 am 03:12 AM

        AgeneratorinPHPisamemory-efficientwaytoiterateoverlargedatasetsbyyieldingvaluesoneatatimeinsteadofreturningthemallatonce.1.Generatorsusetheyieldkeywordtoproducevaluesondemand,reducingmemoryusage.2.Theyareusefulforhandlingbigloops,readinglargefiles,or

        Learning PHP: A Beginner's Guide Learning PHP: A Beginner's Guide Jul 18, 2025 am 04:54 AM

        TolearnPHPeffectively,startbysettingupalocalserverenvironmentusingtoolslikeXAMPPandacodeeditorlikeVSCode.1)InstallXAMPPforApache,MySQL,andPHP.2)Useacodeeditorforsyntaxsupport.3)TestyoursetupwithasimplePHPfile.Next,learnPHPbasicsincludingvariables,ech

        How to access a character in a string by index in PHP How to access a character in a string by index in PHP Jul 12, 2025 am 03:15 AM

        In PHP, you can use square brackets or curly braces to obtain string specific index characters, but square brackets are recommended; the index starts from 0, and the access outside the range returns a null value and cannot be assigned a value; mb_substr is required to handle multi-byte characters. For example: $str="hello";echo$str[0]; output h; and Chinese characters such as mb_substr($str,1,1) need to obtain the correct result; in actual applications, the length of the string should be checked before looping, dynamic strings need to be verified for validity, and multilingual projects recommend using multi-byte security functions uniformly.

        Quick PHP Installation Tutorial Quick PHP Installation Tutorial Jul 18, 2025 am 04:52 AM

        ToinstallPHPquickly,useXAMPPonWindowsorHomebrewonmacOS.1.OnWindows,downloadandinstallXAMPP,selectcomponents,startApache,andplacefilesinhtdocs.2.Alternatively,manuallyinstallPHPfromphp.netandsetupaserverlikeApache.3.OnmacOS,installHomebrew,thenrun'bre

        See all articles