note 59370 rejected from features.file-upload by jome
| From: | jome@php.net | Date: | Mon, 05 Dec 2005 05:38:49 +0000 |
| Subject: | note 59370 rejected from features.file-upload by jome | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-99568@lists.php.net to get a copy of this message | ||
Note Submitter: daniel dot redinger at gmail dot com
----
For some reason, I have not been able to create a working avatar system. It keeps on showing me this
error:
Notice: Undefined index: userfile in /var/www/shadowforum/{PAGE_NAME_HERE}.php on line 140
Invalid file type.
This is my code:
<?php
$maxwidthAva = "50"; // Max width allowed for avatars
$maxheightAva = "50"; // Max height allowed for avatars
if (isset($_POST['uploadit']))
{
$filetypeAva = $_FILES['userfile']['type'];
$filetypexAva = substr($filetypeAva,0,5);
if ($filetypexAva == "image")
{
$newidAva = "images/avatars/";
$newidAva .= base64_encode($user);
$newidAva .= ".gif";
$mysock = GetImageSize($_FILES['userfile']['tmp_name']);
$imagewidth = $mysock[0];
$imageheight = $mysock[1];
if ($imagewidthAva <= $maxwidthAva && $imageheightAva <=
$maxheightAva)
{
if(!(copy($_FILES['userfile']['tmp_name'], $newidAva)))
{
die("Cannot upload files.");
}
echo "You have successfully created a new avatar.";
}
else
{
echo "The avatar you've selected is to big, please change
it.";
}
}
else
{
echo "Invalid file type.";
}
}
else
{
$filename = "images/avatars/".base64_encode($user).".gif";
echo "<center>";
if (file_exists($filename))
{
echo "<img src=\"".$filename."\"
border=\"0\"><br>";
}
else
{
echo "[No Avatar]<br>";
}
?>
</center>
<form action="<?=$_SERVER['REQUEST_URI'] ?>"
method="post" enctype="multipart/form-data">
Select An Image: <input type="file" name="userfile"
size="18">
<br>
<input type="submit" value="Upload Avatar" name="uploadit"
size="18">
</form>
<br><br>
<i>Note: All uploaded files will be converted to .gif format.</i>
<?php
}
?>
Line 140: $filetypeAva = $_FILES['userfile']['type'];
If anyone could help me figure this problem out, I would be tremendously greatful!