首页 \ 问答 \ 使用PHP进行了非常大的上传(Very large uploads with PHP)

使用PHP进行了非常大的上传(Very large uploads with PHP)

我想允许将非常大的文件上传到我们的PHP应用程序(百个兆字节 - 8个演出)。 但是有一些问题。

浏览器:

  • HTML上传有令人沮丧的反馈意见,我们需要对进度进行轮询(这有点愚蠢),或者根本没有显示任何反馈
  • Flash上​​传者在开始上载之前将整个文件放入内存中

服务器:

  • PHP强制我们设置post_max_size,这可能导致易受攻击的DOS攻击。 我不想在全局设置这个设置。
  • 服务器还需要在POST vars中存在一些其他变量,例如秘密密钥。 我们希望能够立即拒绝该请求,而不是在整个文件上传之后。

要求:

  • HTTP是必须的。
  • 只要客户端技术在浏览器中工作,我就很灵活。
  • PHP不是一个要求,如果有一些其他的技术可以在一个linux环境中运行良好,那是非常好的。

I want to allow uploads of very large files into our PHP application (hundred of megs - 8 gigs). There are a couple of problems with this however.

Browser:

  • HTML uploads have crappy feedback, we need to either poll for progress (which is a bit silly) or show no feedback at all
  • Flash uploader puts entire file into memory before starting the upload

Server:

  • PHP forces us to set post_max_size, which could result in an easily exploitable DOS attack. I'd like to not set this setting globally.
  • The server also requires some other variables to be there in the POST vars, such as an secret key. We'd like to be able to refuse the request right away, instead of after the entire file is uploaded.

Requirements:

  • HTTP is a must.
  • I'm flexible with client-side technology, as long as it works in a browser.
  • PHP is not a requirement, if there's some other technology that will work well on a linux environment, that's perfectly cool.

原文:https://stackoverflow.com/questions/864570
更新时间:2022-03-22 22:03

最满意答案

它完成了我需要这个:

/**
    Disable text selection by Chris Barr, of chris-barr.com
*/
$.fn.disableTextSelect = function() {
    return this.each(function(){
        if($.browser.mozilla){//Firefox
            $(this).css('MozUserSelect','none');
        }else if($.browser.msie){//IE
            $(this).bind('selectstart',function(){return false;});
        }else{//Opera, etc.
            $(this).mousedown(function(){return false;});
        }
    });
}

然后我可以禁用我的按钮元素上的文本选择,如下所示:

$(function(){ $('input[type=image]').disableTextSelect(); });

现在我可以快速点击按钮,所有工作正常:-)。


It turended out I need this:

/**
    Disable text selection by Chris Barr, of chris-barr.com
*/
$.fn.disableTextSelect = function() {
    return this.each(function(){
        if($.browser.mozilla){//Firefox
            $(this).css('MozUserSelect','none');
        }else if($.browser.msie){//IE
            $(this).bind('selectstart',function(){return false;});
        }else{//Opera, etc.
            $(this).mousedown(function(){return false;});
        }
    });
}

And then I could disable text selection on my button elements like this:

$(function(){ $('input[type=image]').disableTextSelect(); });

And now I can click buttons fast as hell and all works fine :-).

相关问答

更多
  • 主要区别在于,每次点击时,将检查第一个条件。 所以如果id区域areaA或者tr或者td里面的元素被动态添加,只有第一个可以工作。 The main difference is that the condition in the first one will be checked each time you click. So if the element with id areaA or the tr or td inside is added dynamically, only the first on ...
  • 它完成了我需要这个: /** Disable text selection by Chris Barr, of chris-barr.com */ $.fn.disableTextSelect = function() { return this.each(function(){ if($.browser.mozilla){//Firefox $(this).css('MozUserSelect','none'); }else if($ ...
  • 好吧,我发现这个解决方法,我已经设置元素的CSS为: visibility: hidden; position: absolute; top:0; 它正在上面的每个浏览器上工作。 我会很高兴听到任何其他解决方案。 Ok I found this workaround, I have set the element's css to: visibility: hidden; position: absolute; top:0; it is working on every browser above. I ...
  • 您需要处理所有浏览器的兼容性,而不是切换到可能破坏其他浏览器的解决方案。 验证您是否可以使用解决方案的最简单方法是“if”。 在这种情况下,您可以使用2种解决方案 addEventListener&attachEvent。 var mousewheelevt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel" //FF doesn't recognize mousewheel as of FF3.x if (doc ...
  • 我的特殊情况你可以直接调用函数fetchRowData而不是“触发ondblClickRow事件”。 如果其他一些代码创建了jqGrid并且你真的需要在ondblClickRow (不是事件)上“触发”回调函数,你可以执行以下操作: var ondblClickRowHandler = $("#gridX").jqGrid("getGridParam", "ondblClickRow"); ondblClickRowHandler.call($("#gridX")[0], rowID); I your ...
  • 您可以在更改时获取选择值并使用此值。 喜欢这个: