note 24642 added to features.file-upload
| From: | peter at int8 dot com | Date: | Fri, 23 Aug 2002 23:50:48 +0000 |
| Subject: | note 24642 added to features.file-upload | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-35426@lists.php.net to get a copy of this message | ||
I'm running PHP 4.0.6, and I tried to get Example 20-2 working with $HTTP_POST_FILES for the
uploading of PDF articles for a website. I was unsuccessful, but I was able to come up with a work
around. Here are some code snippets that I used in my working version:
in the html form:
<input type='hidden' name='MAX_FILE_SIZE' value='8000000'>
<input name='article' type='file'>
in the processing php file:
if (is_uploaded_file($article))
{
// $file is composed of variables to ensure that different article types are put in their
corresponding directories
$file = "../articles/" . $section . "/" . $id . ".pdf";
move_uploaded_file($article, $file) or die("Error! File not moved!");
print "File uploaded to: " . $file;
}
else
{
echo "Possible file upload attack. Filename: " . $article_name;
}
--
http://www.php.net/manual/en/features.file-upload.php
http://master.php.net/manage/user-notes.php?action=edit+24642
http://master.php.net/manage/user-notes.php?action=delete+24642
http://master.php.net/manage/user-notes.php?action=reject+24642