How does the $counter variable get from preupload.php to upload.php? $counter is initialized in preupload.php, but I don’t see anywhere where it’s passed through to upload.php
And why does it suddenly look like it’s part of the $photos_uploaded array?
while($counter <= count($photos_uploaded)) {
if($photos_uploaded['size'][$counter] > 0) {
if(!array_key_exists($photos_uploaded['type'][$counter], $photo_types)) {
$result_final .= 'File ' . ($counter + 1) .
' is not a photo<br />';
} else {
// Great the file is an image, we will add this file
}
}
}
while($counter <= count($photos_uploaded)) {
if($photos_uploaded['size'][$counter] > 0) {
if(!array_key_exists($photos_uploaded['type'][$counter], $photo_types)) {
$result_final .= 'File ' . ($counter + 1) .
' is not a photo
';
} else {
// Great the file is an image, we will add this file
}
}
}
Read an old post of mine, thanks to the suggest posts bar at the bottom. I now understand that $photos_uploaded is turned into an multi-dimensional array, but I still don’t see how $counter is referenced from preupload.php without an include file, or being initialized in upload.php.
I did a search on google of if($photos_uploaded[‘size’][$counter] > 0), and other people are using similar code, so it’s something that I’m not getting.
Annnnnnnd I’m pretty sure I figured it out. Took me 3 hours smh. The $counter variable that’s used to display the number of the file in the upload forms of the side of the page, is also passed into $_FILES'[$photo_filename'], by this code here:
I haven’t seen the full code, but I don’t think it is passed around. At the start of that while() loop
while ($counter <= count($photos_uploaded)) {
it’s being used as a loop index from zero (presumably it’s either initialised somewhere, or just auto-created) to the number of entries in the array, so there’s no need for it to be passed.
It’s not shown initialized anywhere else in the code. So either it’s passed, or he left some stuff out.
I’m going through it and trying to rewrite it, to make it current with PHP 5 and because I wanted to try to do some things a different way.