images upload fejl
der sker ikke rigtigt noge skremen er bare hvid hvad kan det skyldes, man skal kunne uploade et nyt images til sin profil med session, og files navn skal skrives i mysql i tablen login under images of billed skal uploades til f.eks. mappen " " på serveren hvad gør jeg forkertupload formen
<form action="changephotoparse.php" method="post" enctype="multipart/form-data">
<strong>
<input type="hidden" name="MAX_FILE_SIZE" value="81920">
Profil billed:</strong>
<input type="file" name="userphoto"><br /><br />
<input type="submit" name="submit" value="Upload Profil billed"></form> <br>
<input type= "button" value="Tilbage" onclick="history.back()" style="cursor:pointer;">
changephotoparse.php
( scriptet der skulle upload og skrive i mysql)
<?php
$id = $_SESSION['navn'];
include("access.php");
$maxfilesize = 81920;
// check if there was a file uploaded
if (!is_uploaded_file($_FILES['userphoto']['tmp_name'])) {
$error = "Du skal huske at vælge en fil der skal oploades.<br />";
// if it was, go ahead with other checks
} else {
if ($_FILES['userphoto']['size'] > $maxfilesize) {
$error = "Dit Profil billed er for stort.<br />";
unlink($_FILES['userphoto']['tmp_name']);
} else {
$ext = strrchr($_FILES['userphoto']['name'], ".");
if ($ext != ".gif" AND $ext != ".jpg" AND $ext != ".jpeg" AND $ext != ".bmp" AND $ext != ".GIF" AND $ext != ".JPG" AND $ext != ".JPEG" AND $ext != ".BMP") {
$error = "Dit profil billed er af forkert filtype.<br />";
unlink($_FILES['userphoto']['tmp_name']);
// if it's there, an okay size and type, copy to server and update the photo value in SQL
} else {
if ($_SESSION['photo'] != "nopic.jpg") {
unlink("/images/".$_SESSION['photo']);
}
$newname = $_SESSION['userphoto'].$ext;
move_uploaded_file($_FILES['userphoto']['tmp_name'],"images/".$newname);
mysql_query("UPDATE login SET images='$newname' WHERE user = '".$id."'"; or die (mysql_error());
$_SESSION['photo'] = $newname;
}
}
}
?>
<?php
if ($error) {
echo "Dit Profil billed kunne ikke ændres fordi ".$error.".";
} else {
echo "Dit nye profil billed er blevet oploadet. se din nye profil, <a href=\"redigerprofil.php\">Klik her</a>.";
}
?>
