Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Two things:</p> <ol> <li>Using Javascript</li> <li>Using APC</li> </ol> <p><strong>Javascript:</strong></p> <pre><code>You can use plupload (http://www.plupload.com/) - pretty good multiple file uploader Pretty decent JS plugin for uploading files in PHP in two methods, 1. normal upload 2. chunk based uploading. </code></pre> <p>Limitations/Assumptions:</p> <pre><code>1. Flash Plugin - in the browser 2. Session problem - since it's flash, a different session's are created for each file upload. </code></pre> <p><strong>APC/PHP</strong></p> <p>Using APC - you can create a progress-bar on our own.</p> <p>Limitation/Assumptions:</p> <pre><code>1. Install APC on the server - using PECL (pecl install APC) 2. Write a separate code to get the status of upload. </code></pre> <p>Code:</p> <p><em>getprogress.php</em></p> <pre><code>&lt;?php if(isset($_GET['progress_key'])) { $status = apc_fetch('upload_'.$_GET['progress_key']); echo $status['current']/$status['total']*100; } ?&gt; </code></pre> <p><em>upload.php</em></p> <pre><code>&lt;?php $id = uniqid(""); ?&gt; &lt;html&gt; &lt;head&gt;&lt;title&gt;Upload Example&lt;/title&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;script type="text/javascript"&gt; function getProgress(){ $.get("getprogress.php?progress_key=&lt;?php echo($id)?&gt;", function(percent) { document.getElementById("progressinner").style.width = percent+"%"; if (percent &lt; 100){ setTimeout("getProgress()", 100); } }); } function startProgress(){ document.getElementById("progressouter").style.display="block"; setTimeout("getProgress()", 1000); } &lt;/script&gt; &lt;iframe id="theframe" name="theframe" src="fileupload.php?id=&lt;?php echo($id) ?&gt;" style="border: none; height: 100px; width: 400px;" &gt; &lt;/iframe&gt; &lt;br/&gt;&lt;br/&gt; &lt;div id="progressouter" style="width: 500px; height: 20px; border: 6px solid red; display:none;"&gt; &lt;div id="progressinner" style="position: relative; height: 20px; background-color: purple; width: 0%; "&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><em>fileupload.php</em> </p> <pre><code>&lt;?php $id = $_GET['id']; ?&gt; &lt;form enctype="multipart/form-data" id="upload_form" action="target.php" method="POST"&gt; &lt;input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="&lt;?php echo $id?&gt;"/&gt; &lt;input type="file" id="test_file" name="test_file"/&gt;&lt;br/&gt; &lt;input onclick="window.parent.startProgress(); return true;" type="submit" value="Upload!"/&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload