You are here: Limit File Size in email form?? « PHP Programming Language « IT news, forums, messages
Limit File Size in email form??

Posted by Jefferis NoSpamme on 07/03/06 01:40

Hi all, I'm trying to limit the file size of an image submission and I keep
running into various problems. I've got most of it working, but I'm stumped
and I have a basic question as to WHY this works at all!

if ($_FILES['file']['size'] !="") {

if ($_FILES['file']['size']<=0) {
header("Location: /fileerror.php");
exit;
}
}


What I want to do is skip this function IF the user submits no file. Part
one works with the !="" condition, but two, which did work, does not when
nested. It stops checking file sizes and submits every size file.

I'm trying to modify Swanilda's tutorial: http://swanilda.com/unix2.html

And using form file's input hidden value:
Code:
<input type="hidden" name="MAX_FILE_SIZE" value="5000" border="0">

WITH this check:
if ($HTTP_POST_FILES['file']['size'] <=0)
{
print "<h2><b>Your picture was not received.</b></h2><br>";
print "The file size was larger than 5k.<br>";
print "Reduce the size and resubmit.";
}


First of all, I don't want to stop the post if the field is empty, so that
is problem 1. But I also don't understand why this code works. This code
blocks an empty file [<=0], but why or how does it check to see that the
file is not larger than that the max file size value of 5k? I don't see a
comparative function or operator here. Why shouldn't you have to write
something like:
Code:
if ($HTTP_POST_FILES['file']['size'] >5000k) or
if ($HTTP_POST_FILES['file'] > ['size'] ) THEN do this?


How is the size value placing a limit on the file size? This code is
probably much simpler than I'm making it out to be, but I've been on 15
sites trying to get this right, and most of the searches are for uploading
files, which I'm not doing. I'm sending them via email.


What I eventually want to do is just prevent submissions IF the user submits
a file and it is larger than 3 megs...
Thank YOU in advance,
Jeff
_________________


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----

 

Navigation:

[Reply to this 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

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