任务进度状态php

时间:2017-01-20 01:18:45

标签: javascript php progress status

大家好我有一个分割远程文件的代码,我需要为用户显示一个进度状态,显示已处理文件和大小的百分比,以MBytes不熟悉javascript和PHP新手

Image][1][1

我找到的所有答案都是关于在本地上传文件并建议使用javascript,这就是我发布请求的方式
任何帮助将不胜感激,谢谢。

已编辑

因为我要使用jscript如何添加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>

到我看起来像这样的PHP代码:

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

.
.
.
?>

0 个答案:

没有答案