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

Any reason why $_FILES['userfile']['error'] wouldn't be populated?

Hi,

I am in the middle of writing an image upload script and am limiting
the size of uploads via upload_max_filesize. This all seems to be
working well, and if I try and upload a bigger file then I get an
UPLOAD_ERR_INI_SIZE sat in $_FILES['userfile']['error']. All hunkey
dorey.

However, in my testing there are one or two large files that cause
problems. PHP appears to abort the upload early as it should, but when
my script runs, $_FILES isn't populated at all?!

I have tried to narrow down the difference in these file but I can't
seem to find anything definate. All the ones that fail are AVI or WMV
files if that gives any clue, but even if I rename them to MPG (others
of which work ok), and check the MIME type being sent up has also
changed to mpg, then they still fail as before. I have sent bigger and
smaller files all ok, so it's not size. I can't see anything in the
filename itself that would cause problems.

Any ideas?

May 27 '07 #1
3 2245
On 27 May 2007 04:38:47 -0700, lister <li************@hotmail.comwrote:
>I am in the middle of writing an image upload script and am limiting
the size of uploads via upload_max_filesize. This all seems to be
working well, and if I try and upload a bigger file then I get an
UPLOAD_ERR_INI_SIZE sat in $_FILES['userfile']['error']. All hunkey
dorey.

However, in my testing there are one or two large files that cause
problems. PHP appears to abort the upload early as it should, but when
my script runs, $_FILES isn't populated at all?!

I have tried to narrow down the difference in these file but I can't
seem to find anything definate. All the ones that fail are AVI or WMV
files if that gives any clue, but even if I rename them to MPG (others
of which work ok), and check the MIME type being sent up has also
changed to mpg, then they still fail as before. I have sent bigger and
smaller files all ok, so it's not size. I can't see anything in the
filename itself that would cause problems.
Do you have error_reporting set to E_ALL? Are there any errors in the Apache
log? (in case PHP's done something unusual - although it doesn't sound like
it's dumping core). What version of PHP?
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
May 27 '07 #2
Do you have error_reporting set to E_ALL? Are there any errors in the Apache
log? (in case PHP's done something unusual - although it doesn't sound like
it's dumping core). What version of PHP?
--
Andy Hassall :: a...@andyh.co.uk ::http://www.andyh.co.ukhttp://www.and....co.uk/space:: disk and FTP usage analysis tool- Hide
Thanks for your pointers. Yes, I have E_ALL reporting on. On looking
in the Apache error log I found I was getting a error about exceeding
post_max_size on the ones that fail, but bizarrely not on the ones
that work, but yet those are larger!! I can only assume there is some
bug in PHP when checking post_max_size because the large ones that
work are VERY large (2GB) (post_max_size is set to 2M)

OK, so checking the PHP site reveals that what I am experiencing seems
to be correct:
"If the size of post data is greater than post_max_size, the $_POST
and $_FILES superglobals are empty. This can be tracked in various
ways, e.g. by passing the $_GET variable to the script processing the
data, i.e. <form action="edit.php?processed=1">, and then checking if
$_GET['processed'] is set."

Thanks again for your help.
May 27 '07 #3
On 27 May 2007 10:36:10 -0700, lister <li************@hotmail.comwrote:
> Do you have error_reporting set to E_ALL? Are there any errors in the Apache
log? (in case PHP's done something unusual - although it doesn't sound like
it's dumping core). What version of PHP?

Thanks for your pointers. Yes, I have E_ALL reporting on. On looking
in the Apache error log I found I was getting a error about exceeding
post_max_size on the ones that fail, but bizarrely not on the ones
that work, but yet those are larger!!
What enctype do you have on the <formfor the upload? If you don't have
enctype="multipart/form-data", it'll upload it using
application/x-www-form-urlencoded.

Because of this, certain files may be encoded to data several times larger
than their original size - but it depends on the content of the file. Mostly
ASCII files would be closer to their original sizes.
>I can only assume there is some
bug in PHP when checking post_max_size because the large ones that
work are VERY large (2GB) (post_max_size is set to 2M)
With files that large then you quite likely run into various 32-bit integer
limits. Many versions of Apache have issues with 2Gb+ files, let alone PHP.
--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
May 27 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ralph Freshour | last post by:
I'm uploading a file to the server - I check the $_FIILES variable to check for exceeding a certain limit (250KB in this case) _ I notice that when I try to upload files of 500KB or 900KB holds...
3
by: Amy Kimber | last post by:
Hello, I have a file upload page, and I've had it working fine, it was beautiful :-) Anyway, the powers that be moved hosts... and it doesn't work now. The file name is correct, the directory...
2
by: Tom Rogie | last post by:
Hello, I'm trying to get my $_FILES arrays into a session because I want to move the files later to a specific directory (ie after I get a result_id from a sql insert). No problem putting the...
2
by: dave | last post by:
Hello, I'm trying to get the below script working, adapted from the manual on php.net. Although i am getting success file uploading, i do not see the file in the tempoary area. And i'm not sure...
9
by: Jankie | last post by:
Greetings ! i hope someone can give me some insights as to what upload method to use of these and if any comparison I found that : if (isset($_FILES)) { works for me in some applications...
9
by: Jankie | last post by:
<?php if(isset($_POST) && $_FILES > 0){ foreach ($_FILES as $key => $error) { $name = $_FILES; $tempname = $_FILES; ………… ……… $path = 'uploads/'; include 'dbcon.php'; $rep = strpos($_FILES,...
15
pradeepjain
by: pradeepjain | last post by:
<?php mysql_connect("localhost", "XXX", "xxx") OR DIE (mysql_error()); mysql_select_db ("XXX") OR DIE ("Unable to select db".mysql_error()); // our sql query $str_sql1="select Tnumber from...
5
by: kailashchandra | last post by:
I am trying to upload a file in php,but it gives me error msg please Help me? My Code is like below:- i have one php file named upload.php and i have another html file named upload.html and...
2
by: Annalyzer | last post by:
My form looks like this: <form action="handle_event.php" method="POST" enctype="multipart/form-data"> <table id="event_edit" border="0"> <tr> <td> ...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.