Pecl Uploadprogress

Hi guys

Just wondering if anybody has any experience of using the PECL extension uploadprogress in Yii?

I found the following stack overflow question but I’m unsure of how to implement it in Yii, especially the part regarding the getting the contents of progress.php using Javascript. Here is the code from stack overflow, but it is the js script and progress.php I’m mostly interested in.


$id = md5(microtime() . rand());


<!DOCTYPE html>


<script type="text/javascript" src="jquery-1.7.2.min.js"></script>

<script type="text/javascript">

        function getProgress(){

            $.get("progress.php", {"ID":'<?php echo $id ?>'}, function(data){



            window.setTimeout(getProgress(), 5000);




    <form onsubmit="getProgress()" target="_self" enctype="multipart/form-data" method="post">

        <input type="hidden" name="UPLOAD_IDENTIFIER" value="<?php echo $id;?>" />

        <label>Select File:</label>

        <input type="file" name="file" />


        <label>Select File:</label>

        <input type="file" name="file2" />


        <label>Upload File:</label>

        <input id="submitButton" type="submit" value="Upload File" />






if (function_exists("uploadprogress_get_info")) {

    $info = uploadprogress_get_info($_GET['ID']);

} else {

    $info = false;


$progress = ($info['bytes_uploaded']/$info['bytes_total'])*100;

echo $progress;

As a little background I have a perfectly working upload form, but it doesn’t use ajax or javascript in any way. It would take quite a bit of work to implement an upload extension instead as there is quite a bit going on and as the uploadprogress extension is already installed on the server, I thought that could be a quick fix.

Any ideas?