Break HTTP file uploading from server side by PHP or Apache

后端 未结 7 1359
盖世英雄少女心
盖世英雄少女心 2020-12-16 01:53

When uploading big file (>100M) to server, PHP always accept entire data POST from browser first. We cannot inject into the process of uploading.

For example, check

7条回答
  •  鱼传尺愫
    2020-12-16 02:03

    I suggest you to use some client side plugins to upload files. You could use

    http://www.plupload.com/

    or

    https://github.com/blueimp/jQuery-File-Upload/

    Both plugins have provision to check file size before uploading.

    If you want to use your own scripts, check this. This may help you

            function readfile()
            {
                var files = document.getElementById("fileForUpload").files;
                var output = [];
                for (var i = 0, f; f = files[i]; i++) 
                {
                        if(f.size < 100000) // Check file size of file
                        {
                            // Your code for upload
                        }
                        else
                        {
                            alert('File size exceeds upload size limit');
                        }
    
                }
            }
    

提交回复
热议问题