re: _FILES

php.internals

Darrel O'Pry

19 years ago
I was wondering if anyone could point me to a resource explaining why the _FILES array is structured as it is with html arrays. I've been googling and reading rfc1867.c and finding very little explanation. The _FILES[$key]['temp_name'][$key] is quite awkward when dealing with multiple uploads. I found it as a bug, but the only response to someone posting about the awkwardness was, it is not a bug and will not be fixed. I'd just really like to know why the structure is the way it is.. It's an inconsistency with other html arrays that really confuses me. If it's old news, please reply to me off list instead of wasting valuable developer time on an old discussion. .darrel.

Brian Moon

19 years ago
Darrel O'Pry wrote:
> I was wondering if anyone could point me to a resource explaining why > the _FILES array is structured as it is with html arrays.
What is an html array?
-- Brian Moon ------------- http://dealnews.com/ It's good to be cheap =)

Darrel O'Pry

19 years ago
On Thu, 2007-02-08 at 17:15 -0600, Brian Moon wrote:
> Darrel O'Pry wrote: > > I was wondering if anyone could point me to a resource explaining why > > the _FILES array is structured as it is with html arrays. > > What is an html array?
Maybe that is not the correct diction. I picked it up somewhere digging through bugs looking for an explanation. But by html arrays I mean specify input names as arrays, that you handle as arrays in php. html array <input name='files[file1]' type='file'> vs. not an html array <input name='file' type='file'>

Vlad Bosinceanu

19 years ago
<input type="text" name="foo[]"> generates $_GET['foo'][0..n] <input type="file" name="foo[]"> generates $_FILES['foo']['tmp_name/name/etc'][0..n] I think this could pretty much be considered an inconsistence but changing wouldn't possible due to the BC demon awakening and wreaking havoc upon doing so. V Darrel O'Pry wrote:

Richard Lynch

19 years ago
On Thu, February 8, 2007 5:15 pm, Brian Moon wrote:
> Darrel O'Pry wrote: >> I was wondering if anyone could point me to a resource explaining >> why >> the _FILES array is structured as it is with html arrays. > > What is an html array?
I believe he means HTTP array such as $_GET $_POST $_REQUEST $_COOKIES $_FILES is a bit bass-ackwards with the keys in an unexpected order, when compared to those others. It always struck me as odd, but I just shrugged and went on with life. I don't think it's something you'd want to change at this point, really, as the BC break would be quite painful. I suppose one could duplicate the array with the keys arranged in a more consistent order in another superglobal, but that's just begging for confusion.
-- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So?

Unknown W. Brackets

19 years ago
I've always assumed it was for security. Imagine something like: <input type="file" name="upload[tmp_name]" /> Realistically, if you tried to access the value as a string, you would get "Array" either way. But I still wouldn't want users to be able to "pollute" $_FILES for people who were assuming a non-array upload. The way it is now, $_FILES['upload']['tmp_name'] is always actually what you think it is, it just might be a string or an array structure. But at least it definitely didn't come from the user. -[Unknown] -------- Original Message --------