HTML: Handling Upload Size

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
captcadaver
Forum Newbie
Posts: 17
Joined: Fri Jul 17, 2009 11:12 pm

HTML: Handling Upload Size

Post by captcadaver »

I'm working on an uploader for a photo gallery.

So, I've got a question about a certain attribute of the HTML input tag used here:

http://www.developershome.com/wap/wapUp ... ?page=php3

Code: Select all

<form action="file_upload.php" method="post" enctype="multipart/form-data">
  <p>
    <input name="MAX_FILE_SIZE" value="1048576" type="hidden"/>
    <input name="myFile" type="file"/>
    <input type="submit"/>
  </p>
</form>
When you use MAX_FILE_SIZE and upload multiple files, does this look at the files' size as an aggregate or individually?
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: HTML: Handling Upload Size

Post by jackpf »

That's quite a good question xD

I'd imagine it applies to each individual input, but I'm not entirely sure. I didn't really find anything on google...

I do hope you're enforcing this server side though, as MAX_FILE_SIZE can be easily overridden.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: HTML: Handling Upload Size

Post by pickle »

It's individual file size. This can be inferred from the fact that in PHP, $_FILES records an error for each individual file, not on the whole upload process. So it's possible to report different errors for different files.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: HTML: Handling Upload Size

Post by jackpf »

The MAX_FILE_SIZE input doesn't relate to php though does it?

I thought it was for the browser to handle.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: HTML: Handling Upload Size

Post by pickle »

It's supposed to be client-side, but that's never stopped any client I've used from trying to upload the file. PHP does have an error value for situations when the file exceeds that value - so those situations are accessible through PHP.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: HTML: Handling Upload Size

Post by jackpf »

Oh right...I didn't know php paid any attention to that. Although that won't stop people using javascript, or simply rewriting the page to overcome that value...
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: HTML: Handling Upload Size

Post by pickle »

Ya. The docs state that is only meant as a convenience to the user, so they don't need to wait around if their file is too large.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply