简体   繁体   English

PHP Uploadprogress扩展函数始终返回null,没有上传数据

[英]PHP Uploadprogress extension function always returning null, with no upload data

I am using php 5.3.2 with uploadprogress extension to get a progressbar during upload using zend framework. 我正在使用带有uploadprogress扩展的php 5.3.2来在上传期间使用zend框架获取进度条。 Even the demo provided with zend is not working. 即使是zend提供的演示也无法正常工作。 code in zend example - zend示例中的代码 -

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. uploadprogress_get_info始终返回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. 我认为我的代码有问题,所以我下载了http://labs.liip.ch/uploadprogresssimple/index.php上提供的工作示例,但即使在uploadprogress_get_info的情况下总是返回null。

My uploadprogress config values 我的uploadprogress配置值

uploadprogress support enabled uploadprogress支持已启用

Version 1.0.1 版本1.0.1

uploadprogress.file.contents_template /tmp/upload_contents_%s uploadprogress.file.contents_template / tmp / upload_contents_%s

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

uploadprogress.get_contents 1 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 当谷歌搜索我发现uploadprogress扩展有一些问题与Suhosin补丁<0.9.26但我使用Suhosin补丁0.9.9.1

Are you testing this locally? 你在本地测试吗? I mean testing this on localhost? 我的意思是在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). 尝试上传到远程主机,或者测试一个相当大的文件(确保你之前碰到了upload_max_filesizepost_max_size )。

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 当谷歌搜索我发现uploadprogress扩展有一些问题与Suhosin补丁<0.9.26但我使用Suhosin补丁0.9.9.1

I am on the same Suhosin version and having this issue. 我有相同的Suhosin版本,并有这个问题。 Also tried apc_fetch() which suhosin has also crippled. 还尝试了apuc_fetch(),其中suhosin也瘫痪了。

What a stupid patch. 多么愚蠢的补丁。 To remove it I have to rebuild php. 要删除它,我必须重建PHP。 For f*** sake! 为了f ***的缘故!

Same problem for me as well though I am using Zend_File_Transfer_Adapter to handle the upload. 虽然我使用Zend_File_Transfer_Adapter来处理上传,但同样的问题对我来说也是如此。 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();
  1. Run phpinfo to check if the UploadProgress is installed and the tmp directory is writable on the server. 运行phpinfo以检查是否已安装UploadProgress且服务器上的tmp目录是否可写。 Meaning the "uploadprogress.file.filename_template" refers to the right tmp folder in the phpinfo. 这意味着“uploadprogress.file.filename_template”指的是phpinfo中正确的tmp文件夹。

  2. You can run the following code to check if uploadprogress is writable. 您可以运行以下代码来检查uploadprogress是否可写。

    <div id="status" style="border: 1px black solid;<?php <div id =“status”style =“border:1px black solid; <?php
    $templateini = ini_get("uploadprogress.file.filename_template"); $ templateini = ini_get(“uploadprogress.file.filename_template”);
    $testid = "thisisjustatest"; $ testid =“thisisjustatest”;
    $template = sprintf($templateini, $testid); $ template = sprintf($ templateini,$ testid);
    $templateerror = false; $ templateerror = false;
    if ($template && $template != $templateini && @touch($template) && file_exists($template)) { if($ template && $ template!= $ templateini && @touch($ template)&& file_exists($ template)){
    // print '('.$templateini.' is writable. The realpath is ' . str_replace($testid,"%s",realpath($template)) .')'; // print'('。$ templateini。'是可写的。真实路径是'.str_replace($ testid,“%s”,realpath($ template))。')';
    unlink($template); 取消链接($模板);
    } else { } else {
    $templateerror = true; $ templateerror = true;
    } }
    if (function_exists("uploadprogress_get_info")) { if(function_exists(“uploadprogress_get_info”)){
    if ($templateerror) { if($ templateerror){
    print 'background-color: red;"'; print'background-color:red;“';
    print ">Problem. "; 打印“>问题。”;
    if ($template == $templateini) { if($ template == $ templateini){
    print "uploadprogress.file.filename_template ($templateini) doesn't have an %s in it for making unique temporary files. Please adjust.<br/>"; print“uploadprogress.file.filename_template($ templateini)中没有%s用于制作唯一的临时文件。请调整。<br/>”;
    } else { } else {
    print "$templateini is NOT writable. <br/>Please make sure the directory exists and is writable for the webserver. <br/> 打印“$ templateini不可写。<br/>请确保该目录存在且可写入网络服务器
    Or adjust the ini setting 'uploadprogress.file.filename_template' to a correct path."; 或者将ini设置'uploadprogress.file.filename_template'调整为正确的路径。“;
    } }
    } else { } else {
    print 'background-color: green;">The uploadprogress extension is installed and initial checks show everything is good'; print'background-color:green;“>安装uploadprogress扩展并初步检查显示一切正常”;
    } }
    } else { } else {
    ?> ?>
    background-color: red;">The uploadprogress extension is not installed. background-color:red;“>未安装uploadprogress扩展。
    <?php } ?> <?php}?>

    </div> </ DIV>

  3. If the above code gives error, point to the correct tmp directory in the php.ini file. 如果上面的代码给出错误,请指向php.ini文件中的正确tmp目录。 The following line was added in the php.ini file for Xampp tmp directory on windows localhost machine. 在windows localhost机器上的Xampp tmp目录的php.ini文件中添加了以下行。 uploadprogress.file.filename_template = C:\\xampp\\tmp\\some_name_%s.txt 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. 现在运行它应该工作的Zend演示或运行以下代码来手动获取var_dump。 var_dump(uploadprogress_get_info($_GET['uploadId'])); 的var_dump(uploadprogress_get_info($ _ GET [ 'UPLOADID']));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM