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
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;
.
.
.
?>