Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

dataform js

<form enctype="multipart/form-data" method="post" name="fileinfo">
  <label>Votre adresse électronique :</label>
  <input type="email" autocomplete="on" autofocus name="userid" placeholder="email" required size="32" maxlength="64" /><br />
  <label>Étiquette du fichier personnalisé :</label>
  <input type="text" name="filelabel" size="12" maxlength="32" /><br />
  <label>Fichier à mettre de côté :</label>
  <input type="file" name="file" required />
  <input type="submit" value="Mettez le fichier de côté." />
</form>
<div></div>
Comment

dataform js

var form = document.forms.namedItem("fileinfo");
form.addEventListener('submit', function(ev) {

  var oOutput = document.querySelector("div"),
      oData = new FormData(form);

  oData.append("CustomField", "Données supplémentaires");

  var oReq = new XMLHttpRequest();
  oReq.open("POST", "stash.php", true);
  oReq.onload = function(oEvent) {
    if (oReq.status == 200) {
      oOutput.innerHTML = "Envoyé !";
    } else {
      oOutput.innerHTML = "Erreur " + oReq.status + " lors de la tentative d’envoi du fichier.<br />";
    }
  };

  oReq.send(oData);
  ev.preventDefault();
}, false);
Comment

PREVIOUS NEXT
Code Example
Javascript :: hide component blur react hooks 
Javascript :: powershell json check if property exists 
Javascript :: map for id 
Javascript :: can i use pipe in switch statement javascript 
Javascript :: regexp substr tester 
Javascript :: ionic vue electron 
Javascript :: Nodemon e criando o Servidor com express 
Javascript :: petShopIndex.html:137 Uncaught ReferenceError: $ is not defined jquery node 
Javascript :: javascript onclick event add html element 
Javascript :: k6 control a live k6 test 
Javascript :: javascript set css after property 
Javascript :: how to get all key values of Json 
Javascript :: remove event ondestroy playcanvas 
Javascript :: lib.js 
Javascript :: dot notation vs bracket notation javascript 
Javascript :: check if key in dictionary javascript 
Javascript :: mocha raise default timeout 
Javascript :: react native segmented control tab 
Javascript :: google sheets simulate edit event 
Javascript :: javascript check if input is empty 
Javascript :: acender lampada javascript 
Javascript :: how to revert parse date in javascript 
Javascript :: scraping from amazon using puppeteer 
Javascript :: format currency javascript 
Javascript :: Import Bootstrap to React Redux CRUD App 
Javascript :: nodejs process object 
Javascript :: FTP upload local file 
Javascript :: return array odd or even outlier 
Javascript :: how create a random enum on postman variable 
Javascript :: Declaring Variables Shorthand javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+1 =