2017-02-09 8 views
1

私はこのコードについて助けが必要です。だから、私はこのコードを書いて、現在、私はプログレスバーを追加し、サーバーにダウンロードしたファイルの後にダウンロードしたファイルのリンクを表示する必要があります... そして、どうすればこのコードに追加できますか? ありがとう!ダウンロードファイルにプログレスバーを追加するには?

<html> 
 
<p style="width: 70%;margin: auto;margin-top: 5%;font-size:larger;text-align:center"> 
 
Download Any Files From Any URL</p> 
 
<form method="post" style="width: 70%;margin: auto;margin-top: 10%;"> 
 
<input name="url" size="50" placeholder="Please Enter Valid URL>>>" style="width: 100%;height: 10%;font-size: 1.5em;padding:10px" required> 
 
<input name="submit" type="submit" value="Start Download" style="width: 30%;height: 10%;margin: 5% auto; display: block;"> 
 
<p style="width: 70%;margin: auto;margin-top: 10%;font-size:larger;text-align:center"> 
 
Your File Downloaded To <?php echo getcwd(); ?> Server</p> 
 
<p style="width: 70%;margin: auto;font-size: smaller;text-align: center;position: fixed;bottom: 0;background: #fff;"> 
 
Powered by: <a href="#" target="_blank" style="color:#f60;text-decoration:none;">Developers</a></p> 
 
</form> 
 
<?php 
 
    // maximum execution time in seconds 
 
    // set_time_limit (24 * 60 * 60); 
 
    if (!isset($_POST['submit'])) die(); 
 
    // folder to save downloaded files to. must end with slash 
 
    $destination_folder = ''; 
 
    $url = $_POST['url']; 
 
    $newfname = $destination_folder . basename($url); 
 
    /* // old script 
 
    $file = fopen ($url, "rb"); 
 
    if ($file) { $newf = fopen ($newfname, "wb"); 
 
     if ($newf) 
 
     while(!feof($file)) { fwrite($newf, fread($file, 1024 * 8), 1024 * 8); } 
 
    } 
 
    if ($file) { fclose($file); } 
 
    if ($newf) { fclose($newf); } 
 
    */ 
 
    file_put_contents($newfname, fopen($url, 'r')); 
 
?> 
 
</html>

私が完了したファイルの後、プログレスバーとショーのリンクを追加する必要があります。

+0

可能な重複に役立つかもしれない(HTTP [私はファイルをダウンロードの進行状況を示すために、jQueryのUIのプログレスバーを使用することはできますか?]: //stackoverflow.com/questions/2595317/can-i-use-jquery-ui-progress-bar-to-indicate-the-progress-of-downloading-a-file) – AxelH

答えて

0

W3学校のブートストラップを使用してプログレスバーの偉大な例があります。

は、お使いのブラウザでこのコードを試してみてください。

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <title>Bootstrap Example</title> 
    <meta charset="utf-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
</head> 
<body> 

<div class="container"> 
    <h2>Animated Progress Bar</h2> 
    <p>The .active class animates the progress bar:</p> 
    <div class="progress"> 
    <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="width:40%"> 
     40% 
    </div> 
    </div> 
</div> 

</body> 
</html> 

ダウンロードが進むにつれて、aria-valuenowの値を変更するという考えがあります。これは、ダウンロードされたファイルのパーセンテージについてphpからの情報を使用し、進行状況を反映するようにaria-valuenowを変更することによって行われます。

+0

ありがとう)私はこのコードを試しましたが、それは動作しません。このスクリプトを実行するより進捗バーが機能しません。それはすべて0%で終わった!この例をスクリプトに追加する手助けはできますか? –

関連する問題