Reply to Re: uploading files

Your name:

Reply:


Posted by Matthew Weier O'Phinney on 10/21/56 11:13

* Marc Serra <mserra@gdwd.com>:
> Hi, i want to create a form to upload a file on a server. My problem is
> that i want to check the filesize before sending it because if the
> filesize is superior than 2 MB it failed and i don't want to wait for a
> long time for uploading a file that will fail.
>
> Can you please give me a solution to check the filesize.

See:
http://php.net/features.file-upload

Basically, you need a MAX_FILE_SIZE hidden attribute in your form:
<input type="hidden" name="MAX_FILE_SIZE" value="2000000" />

However, the manual goes on to say:

The MAX_FILE_SIZE hidden field (measured in bytes) must precede the
file input field, and its value is the maximum filesize accepted. This
is an advisory to the browser, PHP also checks it. Fooling this setting
on the browser side is quite easy, so never rely on files with a
greater size being blocked by this feature. The PHP settings for
maximum-size, however, cannot be fooled. This form element should
always be used as it saves users the trouble of waiting for a big file
being transferred only to find that it was too big and the transfer
failed.

So, adding the above input field is a good first step, but it's not
foolproof; you may still get some too large files uploaded that PHP will
reject after the fact.

--
Matthew Weier O'Phinney | WEBSITES:
Webmaster and IT Specialist | http://www.garden.org
National Gardening Association | http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org
mailto:matthew@garden.org | http://vermontbotanical.org

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация