0

I just realized that one can only POST about 8 MB of data. I have a form to upload multiple files. This files are sent to a php page through POST method where it gets uploaded. Now, I want to check the size of data which will be posted and give an alert message. How can I do that? I googled a bit and found that $_SERVER['CONTENT_LENGTH'] can be used to find this. Unfortunately, I can't figure out how to use it? Here's my form:

<form name="offer" onsubmit="return validateForm()" action="fileupload.php" method="post" enctype="multipart/form-data">
      <tr>
        <td>I9:</td>
        <td> Doc: <input type="file" id="myfile" name="myfile[]"><p id="list"></p></td>
     </tr>
     <tr >
       <td>Client document: </td>
       <td> Doc: <input type="file" id="myfile" name="myfile[]"></td>
     </tr>
      <tr>
         <td>FCRA :</td>
         <td> Doc: <input type="file" id="myfile" name="myfile[]"></td>
      </tr>
      <tr>
        <td>Insurance Certificate :</td>
        <td> Doc: <input type="file" id="myfile" name="myfile[]"></td>
      </tr>
      <tr>
         <td>Work Order :</td>
         <td> Doc: <input type="file" id="myfile" name="myfile[]"></td>
      </tr>

Also, is it possible to display the size of each uploaded file? I know this can be done by javascript. But how?

priyeshrulz
  • 17
  • 1
  • 6
  • Why not modify the php.ini to allow larger uploads? – Jay Blanchard Sep 30 '14 at 20:45
  • http://stackoverflow.com/questions/1606842/how-can-i-get-a-files-upload-size-using-simple-javascript -- top voted answer here is good/simple – eselk Sep 30 '14 at 20:46
  • also: http://stackoverflow.com/questions/7497404/get-file-size-before-uploading http://stackoverflow.com/questions/3717793/javascript-file-upload-size-validation – eselk Sep 30 '14 at 20:46
  • since they are all the same id it will be somewhat more difficult, but input.files[0].size contains the size of a file in a populated input. – dandavis Sep 30 '14 at 21:54

1 Answers1

-2

use this for client side

function findSize() {
    var fileInput =  document.getElementById("_ufile_1");
    try{
        alert(fileInput.files[0].size); // Size returned in bytes.
    }catch(e){
        var objFSO = new ActiveXObject("Scripting.FileSystemObject");
        var e = objFSO.getFile( fileInput.value);
        var fileSize = e.size;
        alert(fileSize);    
    }
}
Harutyun Abgaryan
  • 2,013
  • 1
  • 12
  • 15