Answers for "dataform js"

0

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>
Posted by: Guest on August-09-2021
0

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);
Posted by: Guest on August-09-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language