473,789 Members | 2,806 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_file size. 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 2259
On 27 May 2007 04:38:47 -0700, lister <li************ @hotmail.comwro te:
>I am in the middle of writing an image upload script and am limiting
the size of uploads via upload_max_file size. 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.u k :: 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.u k ::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.ph p?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.comwro te:
> 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_siz e 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="multip art/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.u k :: 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
7530
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 the value and I can check it - however, if I try to upload a 2300KB file is 0 - does anyone know what might be causing this? Why doesn't that large of a file also get recorded in the variable? Thanks...
3
7096
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 where it's going on the server is correct (checked through prints etc.). I've changed the dir to 777 (is that right?) and this is what I get on the print_r($_FILES); line:
2
4383
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 variables in a session but I can't move $_SESSION anymore. $_SESSION is 0 so I don't really see what could be the problem.... Anybody can help?
2
2013
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 where to go as the server confirms file uploaded successfully. Any help appreciated. Thanks. Dave. <?php
9
2100
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 where: if(isset($_POST)) does not How secure is the first method ?
9
2309
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, "image");
15
2337
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 Tenders where Tnumber = '".$_POST."'"; $res_id1=mysql_query($str_sql1); $rec_row=mysql_fetch_row($res_id1); $rows=mysql_num_rows($res_id1); if($rows > 0){
5
6814
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 inside html i am calling php file upload.php:- <?php
2
3174
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> <label for="title">TITLE: </label> </td> <td class="input"> <input id="title" name="title" type="text" size="80" value="<?php if (!empty($title)) {echo $title;} ?>" />
0
9666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10142
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9021
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6769
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5422
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.