das was in bold steht ist ein fehler drin die datei sollte schlussendlich username.jpg oder .gif haben die man über einen radio auswählen kann
PHP-Code:
<?php
$upload_dir = $config_table['userpics_upload_dir'];
$max_size = $config_table['userpics_max_size'];
function upload($upload_dir) {
$max_size = 51200;
if ( $_FILES['userfile']['size'] > $max_size ) {
$kbytes = $max_size / 1042;
if( gettype( $kbytes != Integer) ){
settype( $kbytes, integer );
}
$upload = "Your picture is to big! It has to be smaller than" .
$kbytes . " KB sein";
return $upload;
}
$result = move_uploaded_file( $_FILES['userfile']['tmp_name'],
$upload_dir.$_FILES['userfile']['name'] );
$upload = ($result)? $_FILES['userfile']['name'] . " has been uploaded
to the server! " : $_FILES['userfile']['name'] . " couldn't be uploaded to the
server! ";
return $upload;
}
if( $_FILES['userfile'] ){
if (file_exists($upload_dir.$npdata['username'])) {
unlink($upload_dir.$npdata['username']);
} else {
$upload = upload($upload_dir);
$sql = mysql_query( "UPDATE " . USER_TABLE . " SET userpic = '" .
$_FILES['userfile']['name'] . "' WHERE id = $_SESSION[id] ");
[B]rename($upload_dir.$_FILES['userfile']['name'], $upload_dir.
$npdata['username'].$_REQUEST['picformat']);[/B]
}
}
echo $upload;
?>
<table>
<tr>
[B]<td><input type="text" name="picformat" value="ttd"></td>[/B]
</tr>
</table>
<form name="upload" id="upload" ENCTYPE="multipart/form-data"
method="post">
Choose picture: <input type="file" id="userfile" name="userfile">
<input type="submit" name="upload" value="Upload">
</form>
<table cellspacing="2" cellpadding="1" width="475" border="0">
<tr>
<td class="anews" bgColor="#ADB0B5"> Actual Userpic:</td>
</tr>
</table>
<br><a class="a1">This is <?php echo $npdata['username']; ?>:</a><br>
<img src="images/userpics/<?php echo $npdata['username']; ?>">
EDIT:
linebreak sponsored by asp2php. Bitte zukünftig selbst dafür sorgen, dass man beim lesen nicht scrollen muss.
** vielleicht soll ich zukünftig Verwarnungen jeden verpassen **
Kommentar