file validation
| From: | toni baker | Date: | Fri, 01 Feb 2002 22:02:03 +0000 |
| Subject: | file validation | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-83200@lists.php.net to get a copy of this message | ||
I would like to prevent users from uploading a file
that contains more than 4 pipes or less than 2 pipes.
The code below prevents users from uploading a file
containing more than 4 pipes, but not less than 2
pipes. Should I use awk, ereg, or sed? Thanks
system ("/bin/cat $userfile|/bin/sed -n
's/.*|.*|.*|.*|.*|/&/p'> pipes.txt;
$fd =fopen("pipes.txt", 'r');
$pipes5=fgets($fd,50);
echo ($pipes5);
fclose($fd);
if ($pipes5) {
print "wrong number of pipes";
}
The uploaded file below should not pass but it does:
aaaaa|bbbbb|ccccc|ddddd|eeeee
aaaaa|bbbbb|ccccc|
aaaaa|bbbbb|ccccc|ddddd
aaaaa|bbbbb
aaaaa|bbbbb|ccccc|ddddd|eeeee
__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions!
http://auctions.yahoo.com