473,387 Members | 1,882 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,387 software developers and data experts.

$_FILES [var]['size'] returns 0 for small (30KB) file - why?

I've got a php form handler which takes data from an html page and creates and sends an email with one or more attachments.
I wanted to be smart and make sure a file had a size GREATER THAN 0. So I set
$attachment1_size = $_FILES['attachment1']['size'];
if ($attachment1_size > 0) {
And my 30KB file size comes up 0.
And the error codes showed no error.
When I took out the test for size and assumed (oh, bad) the file had a size >0, the file attached to the email perfectly.
My question is this: why, for a SMALL file, am I getting a 0 size?
The php config upload_max_filesize is 2M. The MAX_FILE_SIZE on the html form is 1000000.
Any suggestions? I'd really like to test the file size.
Apr 6 '11 #1
2 1969
dgreenhouse
250 Expert 100+
That's weird... Are you sure you're not making a mistake in the code somewhere? I'm sure you're actually uploading a "non zero" byte file.

Hmmmmm....
Apr 6 '11 #2
In trying to debug, I echoed the size to check - sure enough, it was zero.
When I commented out the line which tests the size (and its closing bracket), everything worked. So the actual size wasn't zero, even if that's what was in the variable.
Hmm...
Attached Files
File Type: txt Show code on Byte.txt (1.2 KB, 342 views)
Apr 6 '11 #3

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

Similar topics

6
by: Ruben | last post by:
Hello. I am trying to read a small text file using the readline statement. I can only read the first 2 records from the file. It stops at the blank lines or at lines with only spaces. I have a...
4
by: arak123 | last post by:
Lets say i have file with the following structure and the following code snippet: --------------------BEGIN FILE----------------------- name1 name2 name3 name4 ; name5
3
by: Michel de Becdelièvre | last post by:
I have some *performance* trouble reading MathML files in my application (in ASP.Net). - I have small MathML files (2-3k) as input - as (almost) all MathML files these use entities. I have no...
6
by: DMP | last post by:
Hi, I have installed .NetFramework I write following Code in NotePad and save in ******* <html> <body bgcolor="yellow"> <center> <h2>Hello World!</h2> </center> </body>
5
by: ketil | last post by:
Im attempting to develop a small program that will act as a console for private users. Here they can add their favourite .exe files or whatever, with a path and a program/game name. The program...
0
by: nettynet | last post by:
I'm really new in java. I'm trying to read 8000 URL files and write to a file. It's a kind of combining all files together...not overwritten. This is the URL of my all files...
1
by: C. (http://symcbean.blogspot.com/) | last post by:
On Aug 12, 7:08 am, long_way <yilongwei....@gmail.comwrote: Hi, Wouldn't it just be simpler to use Google maps? I'm not overly familiar with greybox, but it should be fairly straightforward...
7
by: Marin Brkic | last post by:
Not commercial distribution, but an academic kind of sorts - giving the exe file to coleagues, so they can use it in their work. Giving ..py file is not an option, since due to centralized computer...
3
by: Susan StLouis | last post by:
I'm writing a program that can be used to compare files. The program features a select that contains a list of files. After selecting several of the files. a "Biggest" button can be pushed to find...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.