3

I am using php 5.3.2 with uploadprogress extension to get a progressbar during upload using zend framework. Even the demo provided with zend is not working. code in zend example -

if (isset($_GET['uploadId'])) {
set_include_path(realpath(dirname(__FILE__) . '/../../../library')
                 . PATH_SEPARATOR . get_include_path());

require_once 'Zend/ProgressBar.php';
require_once 'Zend/ProgressBar/Adapter/JsPull.php';
require_once 'Zend/Session/Namespace.php';

$data          = uploadprogress_get_info($_GET['uploadId']);
$bytesTotal    = ($data === null ? 0 : $data['bytes_total']);
$bytesUploaded = ($data === null ? 0 : $data['bytes_uploaded']);

$adapter     = new Zend_ProgressBar_Adapter_JsPull();
$progressBar = new Zend_ProgressBar($adapter, 0, $bytesTotal, 'uploadProgress');

if ($bytesTotal === $bytesUploaded) {
    $progressBar->finish();
} else {
    $progressBar->update($bytesUploaded);
}

}

uploadprogress_get_info always returns null. I thought something is wrong with my code so i downloaded the working sample available at http://labs.liip.ch/uploadprogresssimple/index.php but even in that case in uploadprogress_get_info always return null.

My uploadprogress config values

uploadprogress support enabled

Version 1.0.1

uploadprogress.file.contents_template /tmp/upload_contents_%s

uploadprogress.file.filename_template /tmp/upt_%s.txt

uploadprogress.get_contents 1

While googling around i found uploadprogress extension has some issue with Suhosin Patch < 0.9.26 but i am using Suhosin Patch 0.9.9.1

abhinavlal
  • 88
  • 2
  • 10

4 Answers4

1

Are you testing this locally? I mean testing this on localhost? try upload to a remote host, or test a rather large file (make sure you bumped upload_max_filesize and post_max_size before).

racetrack
  • 3,766
  • 30
  • 30
  • I'm testing locally from a different computer on lan with firefox throttle addon to simulate slow speed. Upload happens and takes its time to get done. – abhinavlal May 15 '10 at 13:05
1

While googling around i found uploadprogress extension has some issue with Suhosin Patch < 0.9.26 but i am using Suhosin Patch 0.9.9.1

I am on the same Suhosin version and having this issue. Also tried apc_fetch() which suhosin has also crippled.

What a stupid patch. To remove it I have to rebuild php. For f*** sake!

Benbob
  • 13,876
  • 18
  • 79
  • 114
1

Same problem for me as well though I am using Zend_File_Transfer_Adapter to handle the upload. Its useful because you can validate the uploaded file(s) too :)

A couple of useful methods that could help you at least on the configuration of your server is:

Zend_File_Transfer_Adapter_Http::isApcAvailable();
Zend_File_Transfer_Adapter_Http::isUploadProgressAvailable();
lintal
  • 339
  • 3
  • 15
0
  1. Run phpinfo to check if the UploadProgress is installed and the tmp directory is writable on the server. Meaning the "uploadprogress.file.filename_template" refers to the right tmp folder in the phpinfo.

  2. You can run the following code to check if uploadprogress is writable.

    <div id="status" style="border: 1px black solid;<?php
    $templateini = ini_get("uploadprogress.file.filename_template");
    $testid = "thisisjustatest";
    $template = sprintf($templateini, $testid);
    $templateerror = false;
    if ($template && $template != $templateini && @touch($template) && file_exists($template)) {
    // print '('.$templateini.' is writable. The realpath is ' . str_replace($testid,"%s",realpath($template)) .')';
    unlink($template);
    } else {
    $templateerror = true;
    }
    if (function_exists("uploadprogress_get_info")) {
    if ($templateerror) {
    print 'background-color: red;"';
    print ">Problem. ";
    if ($template == $templateini) {
    print "uploadprogress.file.filename_template ($templateini) doesn't have an %s in it for making unique temporary files. Please adjust.<br/>";
    } else {
    print "$templateini is NOT writable. <br/>Please make sure the directory exists and is writable for the webserver. <br/>
    Or adjust the ini setting 'uploadprogress.file.filename_template' to a correct path.";
    }
    } else {
    print 'background-color: green;">The uploadprogress extension is installed and initial checks show everything is good';
    }
    } else {
    ?>
    background-color: red;">The uploadprogress extension is not installed.
    <?php } ?>

    </div>

  3. If the above code gives error, point to the correct tmp directory in the php.ini file. The following line was added in the php.ini file for Xampp tmp directory on windows localhost machine. uploadprogress.file.filename_template = C:\xampp\tmp\some_name_%s.txt

  4. Now run the Zend demo it should work or run the following to get var_dump manually. var_dump(uploadprogress_get_info($_GET['uploadId']));

Syed Waqas Bukhary
  • 5,130
  • 5
  • 47
  • 59