Jump to content

[SOLVED] Avatar upload help


supermerc

Recommended Posts

Im having trouble with my code to upload avatars.

This is my code

[code]<?
session_start();
if (isset($_POST['uploadit'])) {
$filetype = $_FILES['userfile']['type'];
$filetypex = substr($filetype,0,5);

if ($filetypex == image) {
$newid = "/userimage/";
$newid .= "$username";
$newid .= ".gif";
if(!(copy($_FILES['userfile']['tmp_name'], $newid))) die("Cannot upload files.");
echo "Your New Avatar Has Been Created";
}
else {
echo "This File Is Not a Image Fool";
}
}
else {
if ($username != "s_username") {
$filename = 'userimage/'.$username.'.gif';
if (file_exists($filename)) {
echo '<img src="'.$filename.'" border="1" height="250" width="250">';
}
else {
echo "You Do Not Have An Avatar";
}


?>
<form action="<?=$_SERVER['REQUEST_URI'] ?>" method="post" enctype="multipart/form-data">
Select a file <input type="file" name="userfile" size="18">
<br>
<input type="submit" value="Upload My Avatar" name="uploadit" size="18">

<br><br>
<i>All Files Will Be Converted To .gif

<?
}
else {
echo 'not logged in';
}
}
?>
[/code]

This is the error im getting

Warning: copy(/userimage/.gif) [function.copy]: failed to open stream: No such file or directory in /home/xgame/public_html/random/upload.php on line 11
Cannot upload files.
Link to comment
https://forums.phpfreaks.com/topic/31305-solved-avatar-upload-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.