Problems with uploading file: Filesize is zero

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • luftikus143
    New Member
    • Jan 2007
    • 97

    Problems with uploading file: Filesize is zero

    Hi there,

    I am pretty sure that it worked before. But now, neither on my local machine, nor on the server, it does what it is supposed to do: uploading a simple text file.

    Code is as follows:
    Code:
    		<form action="upload_CDIAC.php" method="post" enctype="multipart/form-data">
    			<label for="file">Filename:</label>
    			<input type="file" name="file" id="file" /> &nbsp;&nbsp;
    			<input type="submit" name="submit" value="Submit" />
    		</form>
    and

    Code:
    	if ($_FILES["userfile"]["error"] > 0)
    	{
    		echo "Error: " . $_FILES["userfile"]["error"] . "<br />";
    	}
    	else
    	{
    		echo "Upload: " . $_FILES["userfile"]["name"] . "<br />";
    		echo "Type: " . $_FILES["userfile"]["type"] . "<br />";
    		echo "Size: " . ($_FILES["userfile"]["size"] / 1024) . " Kb<br />";
    		echo "Stored in: " . $_FILES["userfile"]["tmp_name"];
    	}
    So, really nothing fancy, and took it from some PHP tutorial pages.

    Can anyone tell me why "Size: 0 Kb"?

    Thanks for any hints.
  • dgreenhouse
    Recognized Expert Contributor
    • May 2008
    • 250

    #2
    The name you're using in the form is: file and the name you're using in the receiving script is: userfile.

    Comment

    • luftikus143
      New Member
      • Jan 2007
      • 97

      #3
      Sorry, my fault. One shouldn't copy stuff from multiple files. Yes indeed, that was wrong. But my files have it correct. So, it's (now, from the other two files, which I used to use):

      Code:
      		<h1>Upload new news files</h1>
      		<form enctype="multipart/form-data" action="upload_from_gridca2.php" method="post">
      			<!-- <input type="hidden" name="MAX_FILE_SIZE" value="100000"> -->
      			Upload this file: <input name="userfile" type="file">
      			<input type="submit" value="Send File">
      		</form>
      and

      Code:
                  if (is_uploaded_file($_FILES['userfile']['tmp_name']))
                  {
                      $nameNew = date("ymdHis");
      				move_uploaded_file($_FILES['userfile']['tmp_name'], "/xxx/logs/".$nameNew.".log");
      				echo "<br />Uploaded!!<br />";
      			}
      			
      			if ($userfile_size==0)
      			{
      			 echo "Problem: uploaded file is zero length";
      			 exit;
      			}
      And it gives me that error message "uploaded file is zero length"...

      Comment

      • luftikus143
        New Member
        • Jan 2007
        • 97

        #4
        I knew it would be a pretty dumb answer to that dumb question. But just couldn't find the solution... until.... One needs to set in php.ini the upload_max_file size to a higher value....

        Comment

        • munais
          New Member
          • Jan 2012
          • 1

          #5
          Hi
          The reason is very simple. The free space left on your temporary folder (/tmp) is zero. Check it now!

          have a nice day

          Comment

          Working...