473,326 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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:
Expand|Select|Wrap|Line Numbers
  1.         <form action="upload_CDIAC.php" method="post" enctype="multipart/form-data">
  2.             <label for="file">Filename:</label>
  3.             <input type="file" name="file" id="file" /> &nbsp;&nbsp;
  4.             <input type="submit" name="submit" value="Submit" />
  5.         </form>
and

Expand|Select|Wrap|Line Numbers
  1.     if ($_FILES["userfile"]["error"] > 0)
  2.     {
  3.         echo "Error: " . $_FILES["userfile"]["error"] . "<br />";
  4.     }
  5.     else
  6.     {
  7.         echo "Upload: " . $_FILES["userfile"]["name"] . "<br />";
  8.         echo "Type: " . $_FILES["userfile"]["type"] . "<br />";
  9.         echo "Size: " . ($_FILES["userfile"]["size"] / 1024) . " Kb<br />";
  10.         echo "Stored in: " . $_FILES["userfile"]["tmp_name"];
  11.     }
So, really nothing fancy, and took it from some PHP tutorial pages.

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

Thanks for any hints.
Jan 18 '10 #1

✓ answered by luftikus143

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_filesize to a higher value....

4 12266
dgreenhouse
250 Expert 100+
The name you're using in the form is: file and the name you're using in the receiving script is: userfile.
Jan 18 '10 #2
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):

Expand|Select|Wrap|Line Numbers
  1.         <h1>Upload new news files</h1>
  2.         <form enctype="multipart/form-data" action="upload_from_gridca2.php" method="post">
  3.             <!-- <input type="hidden" name="MAX_FILE_SIZE" value="100000"> -->
  4.             Upload this file: <input name="userfile" type="file">
  5.             <input type="submit" value="Send File">
  6.         </form>
and

Expand|Select|Wrap|Line Numbers
  1.             if (is_uploaded_file($_FILES['userfile']['tmp_name']))
  2.             {
  3.                 $nameNew = date("ymdHis");
  4.                 move_uploaded_file($_FILES['userfile']['tmp_name'], "/xxx/logs/".$nameNew.".log");
  5.                 echo "<br />Uploaded!!<br />";
  6.             }
  7.  
  8.             if ($userfile_size==0)
  9.             {
  10.              echo "Problem: uploaded file is zero length";
  11.              exit;
  12.             }
And it gives me that error message "uploaded file is zero length"...
Jan 18 '10 #3
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_filesize to a higher value....
Jan 18 '10 #4
munais
1
Hi
The reason is very simple. The free space left on your temporary folder (/tmp) is zero. Check it now!

have a nice day
Jan 5 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: lion | last post by:
I get these errors when uploading images via a web page: (the page still uploads the images but reports these errors?) Warning: fopen(D:\php\uploadtemp\php1FC7.tmp) : failed to create stream: No...
1
by: Chris Kennedy | last post by:
I am having problems uploading web apps to our local server. Can anyone shed any light on the explanation I have been given by one of our techies. You have recreate the virtual and add server...
6
by: jackson | last post by:
Hi all, Im having problem when uploading file to localhost. but I can upload to drive c: any idea thanks
0
by: Monica | last post by:
I have a problem with uploading file into SQL 2005 DB using IIS 6.0 webserver, this code was working in SQL 2000 Db and IIS 5.0. Can you please help me to see what the problem is. Error msg :...
0
by: Mika M | last post by:
Hi! I'm uploading file(s) over internet like... My.Computer.Network.UploadFile("C:\file1.txt", "ftp://some.domain.com/file1.txt", "MyUID", "MyPWD", False, 1000) ....and this is working...
3
by: detrox | last post by:
Hi, all I have two questions about uploading files using php & html: 1. How can i add a `file type' in the pop window when i click `browse' button of the `<input type=file>'. 2. How can i get...
1
by: jimmylee | last post by:
Hi All, Please help me . I am getting aspSmartUploadfile error while uploading file I have already instrall aspSmartUpload.dll and aspSmartUploadutil.dll. how to solve this error. thanks....
4
by: ish | last post by:
hello everybody...... plz help me out... how we can store the acual path of uploading file.i want to store the path of file in my database...bt i m not getting anyway to implement that......if...
1
by: Piotrekk | last post by:
Hi My application is uploading the file to the ASP script. I am dealing with situation where ASP script is not interested in receiving a file. I simulate this by returning from ASP script: ...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.