Avatar upload and quck set
Started on the old forum in July 2010 · view the original in the archive · old links redirect here
i posted one in lava mods topic ages ago lol ...not very safe 1 tho lol
it should do .... its probably a wrong folder name/ address .... might need a / infront of path address see below
}else if($action=="uploadav"){
echo '<form enctype="multipart/form-data" action="genproc.php.php?action=uploadav&sid=$sid" method="POST">
Pic: <input name="pic" type="file"/><br/>
<input type="submit" value="Upload"/>
</form>';
}
}else if($action=="uploadav"){
$path="avatars/".$HTTP_POST_FILES['pic']['name']; // change avatars to your folder name
if($pic!="none")
{
if(copy($HTTP_POST_FILES['pic']['tmp_name'], $path))
{
echo "Successful<br/>";
mysql_query("UPDATE ibwf_users SET avatar='".$path."' WHERE uid='".$uid."'");
//line above might need changing to
// mysql_query("UPDATE ibwf_users SET avatar='/".$path."' WHERE uid='".$uid."'");
}
else
{
echo "Error<br/>";
}
}
}
Thanks
Thanks for this helpful code, but when i was put that, that was not working. after this little change on code that's working as well.... thanks again. on index.php
///////////////////////////////////Settings
else if($action=="uploadav")
{
echo "<head>";
echo "<title>$sitename- User Settings- Avatar</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
include("header.php");
echo "<p align=\"center\">";
echo "<b>Select a Picture to Set as Your Avatar</b>";
echo "</p>";
echo "<p>";
echo "<form enctype=\"multipart/form-data\" action=\"genproc.php?action=uploadav&sid=$sid\" method=\"POST\">
Select Avatar: <input name=\"pic\" type=\"file\"/><br/>
<input type=\"submit\" value=\"Upload\"/>
</form>";
echo "</p>";
include("footer.php");
echo "</body>";
}
and on genproc.php
//////////////////////////////////////////Upload Avater
else if($action=="uploadav")
{
$path="../avatars/".$HTTP_POST_FILES['pic']['name']; // change avatars to your folder name
if($pic!="none")
{
if(copy($HTTP_POST_FILES['pic']['tmp_name'], $path))
{
echo "<head>";
echo "<title>$sitename- Upload Avatar Successful</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
include("header.php");
echo "<p align=\"center\">";
echo "Avatar Changes Successful<br/>";
mysql_query("UPDATE ibwf_users SET avatar='".$path."' WHERE id='".$uid."'");
echo "</p>";
include("footer.php");
echo "</body>";
}
else
{
echo "<head>";
echo "<title>$sitename- Upload Avatar Failed</title>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../themes/$theme[0]\">";
echo "</head>";
echo "<body>";
include("header.php");
echo "<p align=\"center\">";
echo "Avater Changes Failed<br/>";
echo "</p>";
include("footer.php");
echo "</body>";
}
}
}