Search the Community
Showing results for tags 'progressbar'.
-
I was wondering if there is a way to add an progress bar to this script that uploads files to a sql database <!DOCTYPE html> <head> <title>MySQL file upload</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body> <form action="add_file.php" method="post" enctype="multipart/form-data"> <input type="file" name="uploaded_file"><br> <input type="submit" value="Upload file"> </form> <p> <a href="list_files.php">See all files</a> </p> <p> <a href="search.php">Search Database</a> </p> </body> </html> If so, how would i go about doing that?
- 3 replies
-
- upload
- progressbar
-
(and 1 more)
Tagged with:
-
Hi, I want to implement a progress bar. The idea is simple, I have file2.php where I set $_SESSION['progress'] value in each loop. While file2 is working in background, I want to return the $_SESSION['progress'] value in main thread using below functions. But the problem is, it is not working. While fprogress is being called in every second, the value is set only once at the end. Can anybody please help? Thanks, var updateprog; function fprogress() { var progxmlHttp = new XMLHttpRequest(); var progress; var url = "file1.php"; progxmlHttp.onreadystatechange=function(){ if (progxmlHttp.readyState==4 && progxmlHttp.status==200){ progress = progxmlHttp.responseText; document.getElementById("progress").innerHTML ="Progress: "+progress+"% <br><br>"; } } progxmlHttp.open("GET", url, true); progxmlHttp.send(null); } function updateAll(mid) { var xmlhttp=new XMLHttpRequest(); updateprog = window.setInterval(fprogress,1000); xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ window.clearInterval(updateprog); document.getElementById("progress").innerHTML ="progress: 100% <br><br>"; } } xmlhttp.open("POST","file2.php",true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); params = "key=xxx"; xmlhttp.send(params); } file1.php <?php if (!isset($_SESSION)) { session_start(); } echo $_SESSION['progress']; ?>