• <label id="t6syy"></label>
  • <center id="t6syy"><optgroup id="t6syy"></optgroup></center>

    <span id="t6syy"></span>
      <bdo id="t6syy"></bdo>

      \r\n    \r\n      請(qǐng)拖入上傳的文件\r\n    <\/div>\r\n  <\/body>\r\n<\/html><\/pre>

      upload.php<\/p>

      XMLhttpReuest.js<\/p>

      function ajaxFunction()\r\n {\r\n var xmlHttp;\r\n try\r\n  {\r\n  \/\/ Firefox, Opera 8.0+, Safari\r\n  xmlHttp=new XMLHttpRequest();\r\n  }\r\n catch (e)\r\n  {\r\n \/\/ Internet Explorer\r\n  try\r\n   {\r\n   xmlHttp=new ActiveXObject(\"Msxml2.XMLHTTP\");\r\n   }\r\n  catch (e)\r\n   {\r\n   try\r\n     {\r\n     xmlHttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\r\n     }\r\n   catch (e)\r\n     {\r\n     alert(\"您的瀏覽器不支持AJAX!\");\r\n     return false;\r\n     }\r\n   }\r\n  }\r\n  return xmlHttp;\r\n}<\/pre>

      All of the above That’s the entire content of this article, I hope you all like it. <\/p>\n

      For more articles related to Js+php implementing asynchronous drag-and-drop uploading files, please pay attention to the PHP Chinese website! <\/p>"}

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

      Home php教程 PHP開(kāi)發(fā) Js+php implements asynchronous drag and drop upload files

      Js+php implements asynchronous drag and drop upload files

      Dec 30, 2016 pm 01:19 PM

      Asynchronous drag and drop upload file--small example

      upload.html

      <!DOCTYPE html>
      <!--
      To change this license header, choose License Headers in Project Properties.
      To change this template file, choose Tools | Templates
      and open the template in the editor.
      -->
      <html>
        <head>
          <title>TODO supply a title</title>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <style>
            #box{
              width:150px;height: 150px;border: 1px solid red;
            }
          </style>
          <script type="text/javascript" src="XMLhttpReuest.js"></script>
          <script>
            window.onload = function () {
              var box = document.getElementById(&#39;box&#39;);
              box.ondragenter = function (e) {
                e.preventDefault();
              }
              box.ondragover = function (e) {
                e.preventDefault();
              }
              box.ondragleave = function (e) {
                e.preventDefault();
              }
              box.ondrop = function (e) {
                e.preventDefault();
                var file = e.dataTransfer.files[0];
                var formData = new FormData();
                formData.append(&#39;aa&#39;, file);
        
                var xml = ajaxFunction();
                xml.open("post", &#39;./upload.php&#39;, true);
                xml.send(formData);
                xml.onreadystatechange = function () {
                  if (xml.readyState == 4 && xml.status == 200) {
                    var flag = xml.responseText;
                    console.log(flag);
                    if (flag == 1) {
      //                box.innerHTML="上傳成功";
                      alert(&#39;上傳成功&#39;);
                    }
                  }
                }
              }
        
        
            }
          </script>
        </head>
        <body>
          <div id="box">
            請(qǐng)拖入上傳的文件
          </div>
        </body>
      </html>

      upload.php

      <?php
      header("Content-Type:text/html;charset=UTF-8");
      if(is_uploaded_file($_FILES[&#39;aa&#39;][&#39;tmp_name&#39;])){
          move_uploaded_file($_FILES[&#39;aa&#39;][&#39;tmp_name&#39;], "./".iconv("UTF-8", "GBK", $_FILES[&#39;aa&#39;][&#39;name&#39;]));
          echo &#39;1&#39;;
      }

      XMLhttpReuest.js

      function ajaxFunction()
       {
       var xmlHttp;
       try
        {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
        }
       catch (e)
        {
       // Internet Explorer
        try
         {
         xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
         }
        catch (e)
         {
         try
           {
           xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
           }
         catch (e)
           {
           alert("您的瀏覽器不支持AJAX!");
           return false;
           }
         }
        }
        return xmlHttp;
      }

      All of the above That’s the entire content of this article, I hope you all like it.

      For more articles related to Js+php implementing asynchronous drag-and-drop uploading files, please pay attention to the PHP Chinese website!

      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