Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
Design
/
fileman
/
Fusion
/
upload_file
/
0013
:
code.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<!-- https://elevenstechwebtutorials.com/detail/25/how-to-upload-file-using-javascript-and-php --> <script> var content_coockie; function uploadData() { //get input file value var content = document.getElementById("file").files; if(content.length > 0 ){ var formData = new FormData(); formData.append("file", content[0]); //formData.append('user', 'person'); var xhttp = new XMLHttpRequest(); // ajax file path and Set POST method xhttp.open("POST", "fileUpload.php", true); // call on request on ready changes state xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { var res = JSON.parse(this.responseText); console.log(res.var1); console.log(res.var2); console.log(res.var3); content_coockie = res.var3; var response = this.responseText; if( res.var1 == 1 ) //if(response == 1) { //alert("Upload File Successfully."); document.getElementById("affichage").innerHTML = "Le fichier a été téléchargé , redirection en cours ..."; //setTimeout(myURL(res.var3), 10000); // setTimeout(redir(res.var3),10000) //setTimeout(10000); //setTimeout(codingCourse, 10000); /*for (let i = 0; i <= 200000; i++) { console.log(i); } */ //await sleep(10000); // window.location.href = "https://www.google.fr"; redirect(); }else{ alert("File Not Uploaded Successfully."); } } }; // Send request with data xhttp.send(formData); }else{ alert("Please Select A File"); } } function redirect () { // var interval = setInterval(myURL(), 10000); // var result = document.getElementById("result"); //result.innerHTML = "<b> The page will redirect after delay of 5 seconds setInterval() method."; console.log(" ------ " + content_coockie); for (let i = 0; i <= 200000; i++) { console.log(i); if( i == 200000 ) { window.location.href = content_coockie; } } } function myURL() { //document.location.href = 'https://www.clubic.com'; console.log(content_coockie); window.location.href = content_coockie; //"https://www.google.fr"; clearInterval(interval); } function codingCourse() { console.log("Wait 10 s"); } function xxxxmyURL(xxxxxurl) { //document.location.href = 'https://www.tutorialspoint.com/index.htm'; document.location.href = xxxxxurl; } function redir(val) { self.location.href=val alert("plouf"); } </script> <input type="file" name="file" id="file" class="form-control"> <button type="button" class="btn btn-primary btn-lg" onclick="uploadData();" >Upload</button> <input type="hidden" value="person" name="user"> <p id="affichage"></p> <?php $value = "https://www.tutorialspoint.com/index.htm"; // cookie will expire in 1 hour setcookie("myCookie", $value, time() + 3600); ?>