[ Index ]

PHP Cross Reference of Project BDR

title

Body

[close]

/ -> uploadfile.html (source)

   1  <!DOCTYPE html>
   2  <html>
   3   
   4  <head>
   5      <title>
   6          HTML | File upload example
   7      </title>
   8      <script type="text/javascript">
   9      </script>
  10  </head>
  11   
  12   <body>
  13   <h2>Hi Users Choose your file and Click upload.</h2>
  14    <!-- Input Form Elements HTML 5 -->
  15    <input id="fileupload" type="file" name="fileupload" /> 
  16    <button id="upload-button" onclick="uploadFile()"> Upload file </button>
  17  
  18    <!-- File Upload Logic JavaScript -->
  19    <script>
  20    async function uploadFile() {
  21        //creating form data object and append file into that form data
  22    let formData = new FormData(); 
  23    formData.append("file", fileupload.files[0]);
  24        //network request using POST method of fetch
  25    await fetch('PASTE_YOUR_URL_HERE', {
  26      method: "POST", 
  27      body: formData
  28    }); 
  29    alert('You have successfully upload the file!');
  30    }
  31    </script>
  32  
  33   </body> 
  34  <html>


Generated: Thu Sep 14 10:56:15 2023 Cross-referenced by PHPXref 0.7.1