No refresh upload file

Source: Internet
Author: User

Use JS to give an upload file without refreshing the page scheme


<input id= "Upload" type= "file"/> <button id= "upload-btn" >upload</button>


    document.getelementbyid (' upload-btn '). Onclick = function () {           var oinput = document.getelementbyid (' upload ');           var file = oInput.files[0];        //Selecting Files         var formdata  = new formdata ();    //creating form Data Objects          Formdata.append (' file ', file);     //adding files to form objects          fetch ({                           //Transmission              url: './',             mothod: ' POST ',             body:formdata          })          .then ((d) =>{         console.log (' Result is ', D);         Alert ("Upload complete! ")         })     }


To achieve such an effect:


use Html+css to implement layout, border-width:5px, grid size is 50px*50px,hover, the border turns red and you need to consider semantics.

650) this.width=650; "Src=" https://uploadfiles.nowcoder.com/images/20170728/826546_1501229843213_ D08da487e4be8f2e89257e85d2ddd1ee "style=" border:0px;vertical-align:middle; "/>


        table{             border-collapse:collapse;   /*  set a merge border model for a table  */             margin:50px;             text-align:center;  /*  Set Text Center  */         }          table tr{             border:none;         }         table.tab td{             width:50px;             height:50px;             border:5px  inset blue;        }          table.tab td:hover{            border :5px solid red;            cursor:  pointer;        }
        <table class= "tab" >         <tr>            <td> 1</td>            <td>2</td>             <td>3</td>         </tr>        <tr>             <td>4</td>             <td>5</td>             <td>6</td>         </tr>        <tr>             <td>7</td>            <td> 8</td>            <td>9</td>         </tr>    </table>




No refresh upload file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.