Welcome to WebmasterWorld Guest from 220.127.116.11 , register , free tools , login , search , subscribe , help , library , announcements , recent posts , open posts Subscribe to WebmasterWorld
I can't seem to count php count function Gibisan msg:3032520 6:00 am on Aug 3, 2006 (gmt 0) I have just moved my site to a new server and my image upload script is failing due to an inability to count the file array.
The upload form code allows a max of four images - the form code for an image looks like
<input name="userfile" onchange="return TestFileType(this);" type="file" />
When this form is posted the new script starts by finding how many image files have been uploaded
$tot = count($userfile);
The problem is that $tot is always 0. count() does not seem to be able to count!
I have checked that a file is being uploaded using $_FILES['userfile']['name'] and it is.
This worked fine on the old server.
I realise I could just loop though the filename array until I dont find one but I'd rather just leave the script unchanged. Any ideas where the problem lays?
Gibisan msg:3032528 6:15 am on Aug 3, 2006 (gmt 0)
Ahh - I think the problem is with register_globals being off. Problem solved. coopster msg:3032805 12:39 pm on Aug 3, 2006 (gmt 0)
Using Register Globals [ php.net] was a security meausure addressed quite a few releases back. It is not good practice to continue using them as such. You'll want to read that manual page and address your issue as soon as possible. Gibisan msg:3033766 2:57 am on Aug 4, 2006 (gmt 0)
I did read all about it yesterday before just switching register_globals on. Once I realised the security implications I changed my scripts to use $tot = count($_FILES['userfile']['tmp_name']); as the count and then $_POST['item'][num] throughout. Bye bye register_globals coopster msg:3034250 1:59 pm on Aug 4, 2006 (gmt 0)
Good for you, that's the best way to handle it. Congrats.