0

hi guys I have a code that split remote files and I need to put a progress status for the user that show percentage of processed file and size in MBytes am not familiar with javascript and new to PHP

Image][1][1

all answers that I found is about uploading files locally and advising the use of javascript, so that's the way I am posting my request
any help will be greatly appreciated thank you.

EDITED

since am going to use jscript how to add that jscript

<!DOCTYPE html>
<html>
<style>
#myProgress {
  position: relative;
  width: 100%;
  height: 30px;
  background-color: #ddd;
}

#myBar {
  position: absolute;
  width: 10%;
  height: 100%;
  background-color: #4CAF50;
}

#label {
  text-align: center;
  line-height: 30px;
  color: white;
}
</style>
<body>

<h1>JavaScript Progress Bar</h1>

<div id="myProgress">
  <div id="myBar">
    <div id="label">1%</div>
  </div>
</div>

<br>
<button onclick="move()">Click Me</button> 

<script>
function move() {
  var elem = document.getElementById("myBar");   
  var width = 10;
  var id = setInterval(frame, 50);
  function frame() {
    if (width >= 100) {
      clearInterval(id);
    } else {
      width++; 
      elem.style.width = width + '%'; 
      document.getElementById("label").innerHTML = width * 1  + '%';
    }
  }
}
</script>

</body>
</html>

to my php code that look like that:

<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="POST">
<fieldset>
    <legend><h2><b>Uploading Files Area:</b></h2></legend>
    <table>
    <tr><td>Past the file Url Here Please:</td>
        <td><input  name="filename" size="120" type="url" /></td><br></tr>       
    <tr><td>Enter the file Size will split to :</td>
        <td><input  name="piecesize" maxlength="4" size="2" min="1" max="1024" type="number" /> MB.</td><br>
    </tr></table>
    <input type="submit" value="submit" />

</form>

<?php
$filename = $piecesize = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
  $filename = test_input($_POST["filename"]);
  $piecesize = test_input($_POST["piecesize"]);
}

function test_input($data) {
  $data = trim($data);
  $data = stripslashes($data);
  $data = htmlspecialchars($data);
  return $data;
}      
if(isset($_POST['filename']) && isset($_POST['piecesize']))
   {
$base_filename = basename($filename);
     echo "<fieldset><table>";
        echo "<tr><td><b>FILE NAME   : </b></td><td>$base_filename</h3></td></tr>";
       echo '<br>';
        echo "<tr><td><b>SIZE OF SPLIT: </b></td><td>$piecesize MB</td></tr>";
     echo "</table></fieldset>";

$targetfolder = 'tmp';


$buffer = 1024;
$piece = 1048576*$piecesize;
$current = 0;
$splitnum = 1;

.
.
.
?>
autodidact
  • 88
  • 1
  • 1
  • 7
  • 1
    What is wrong with the use of javascript? Also, uploading "locally" is just on a local server. Otherwise you are just copying and pasting it around your computer. – Nytrix Jan 20 '17 at 01:34
  • How about googling it yourself? If I give you an answer I need to google it as well, so I'll leave that to you. Here a little starter: http://stackoverflow.com/questions/849237/upload-progress-bar-in-php – Nytrix Jan 20 '17 at 15:31
  • @Nytrix am not uploading am procession a file from url i mean the code read from url and split the file so i posted a jscript down and part of my php code feel free to read it please should i put a variable in jscript or what thank you. – autodidact Jan 20 '17 at 15:42
  • Yes, so you can *edit* your post in order to add code or anything else. Are you not uploading, but downloading to the server from another source? – Nytrix Jan 20 '17 at 15:48

0 Answers0