Closed Thread Icon

Preserved Topic: multiple file uploads w/PHP Pages that link to <a href="https://ozoneasylum.com/backlink?for=21152" title="Pages that link to Preserved Topic: multiple file uploads w/PHP" rel="nofollow" >Preserved Topic: multiple file uploads w/PHP\

 
Author Thread
butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 05-15-2002 00:21

Why is it when I do this:

$image_name = $_FILES['userfile']['name'][0];
$userf = $userfile[0];

it works fine, but when I try and do the same thing in a loop using a variable for the [0] part it doesn't work. I mean like this:

for($i = 0; $i <= sizeof($userfile); $i++)
{
$image_name = $_FILES['userfile']['name'][$i];
$userf = $userfile[$i];
}

I realize it doesn't like the "$i" part of the equation but I don't know why, or what to put in their to make it work.

Thanks very much



-Butcher-

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 05-15-2002 00:48

dont know.
but the first thing i'd try is
count($userfile); instead of sizeof($userfile);

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 05-15-2002 02:27

Thanks Grumble

It's not the looping part itself I'm having trouble with.

When I do this:


$image_name = $_FILES['userfile']['name'][0];
echo $image_name;


The image name I am expecting shows up on the screen.

When I do this:


$i = 0;
$image_name = $_FILES['userfile']['name'][$i];
echo $image_name;


Nothing shows up on the screen

To me they are the same thing.



-Butcher-

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 05-15-2002 02:53

freaky deaky it looks good

try ["$i"]



.:[ The Tao of Steve ]:.
Be Desireless
Be Excellent
Be Gone
...................................

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 05-15-2002 03:01

butcher: I had a slightly similar problem but my solution isn't really applicable. Try bitdamaged's way and if that doesn't work:

code:
for($i = 0; $i <= sizeof($userfile); $i++)
{
$end_bit = "[$i]";
$image_name = $_FILES['userfile']['name']$end_bit;
ETC.



Emps

butcher
Paranoid (IV) Inmate

From: New Jersey, USA
Insane since: Oct 2000

posted posted 05-15-2002 03:34

Thanks a lot guys

Bitdamaged's tip did the trick. I'm tempted to try Emperor's suggestion just so I can have a reason to use a variable with the name $end_bit in my code. I was kinda tickled by that for some reason. I must be tired.

I appreciate all the replys.

Thanks!

-Butcher-

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 05-15-2002 03:56

butcher: It probably wouldn't have worked anyway - glad to see it was fixed and feel free to use that name somewhere else in another script

Emps

GRUMBLE
Paranoid (IV) Mad Scientist

From: Omicron Persei 8
Insane since: Oct 2000

posted posted 05-15-2002 12:30

creepy.

« BackwardsOnwards »

Show Forum Drop Down Menu