upload form limiting
Moderator: General Moderators
-
SL-Cowsrule
- Forum Newbie
- Posts: 13
- Joined: Sat Oct 12, 2002 5:08 pm
upload form limiting
Im not sure if i can use MIME types for this, but if you know how to limit the kind/type of file that can be uploded, please post here.
Thanks,
CoW
Thanks,
CoW
I think the best thing to do is to check the file type after it's been uploaded temporily.
You can check the array $HTTP_POST_FILES['userfile']['tmp_name'] if you are using php.
Something like
You can read an article about it here:
http://www.phpfreaks.com/tutorials/36/0.php
You can check the array $HTTP_POST_FILES['userfile']['tmp_name'] if you are using php.
Something like
Code: Select all
<?php
if ($HTTP_POST_FILESї'imagefile']ї'type'] == "image/gif")
{
// do something here
}
else
{
echo 'sorry, wrong file type!';
}
?>http://www.phpfreaks.com/tutorials/36/0.php
http://www.w3.org/TR/html4/interact/for ... def-accept
i.e.will accept all text-files (text/plain, text/html, ....).
But that's courtesy of the browser, so a server-side check is mandatory to be sure
i.e.
Code: Select all
<input type="file" accept="text/*" name="ufile" />But that's courtesy of the browser, so a server-side check is mandatory to be sure
Or you could check the extension
Code: Select all
<?php
if(substr($file,-1,-3) == "gif") {
echo "It's a GIF file";
}
?>only as example:
what ever 'Procedure Builder' is
it uses .tml as extension for "Export for Task Manager file"
http://www.aiai.ed.ac.uk/~entprise/ente ... BUIL94.htm
what ever 'Procedure Builder' is
it uses .tml as extension for "Export for Task Manager file"
http://www.aiai.ed.ac.uk/~entprise/ente ... BUIL94.htm
naaa, I'll wait for mime-magic.
Until than I use
Until than I use
Code: Select all
substr($fname, strrpos($fname, '.'))- mydimension
- Moderator
- Posts: 531
- Joined: Tue Apr 23, 2002 6:00 pm
- Location: Lowell, MA USA
- Contact:
why not just use strrchr()
Code: Select all
$str = "some.weird.file.name";
$result = strrchr($str, ".");
//$result now equals ".name"