<?php
session_start();
include 'config.php';
$photo=$_POST['pic'];
$file = $_FILES['userfile']['tmp_name'];
$valid = array (".png",".jpg",".jpeg",".gif",".ico",".tif");
////////////////////////////////////////
$nameext= $_FILES['userfile']['name'];
$ext = strtolower(strrchr($nameext, "."));
$namei=$_SESSION['username'].$ext;
////////////////////////////////////////
if ($photo=='avatar'){
$path='images/avatars/'.$namei;}
elseif ($photo=='propic'){
$path='images/photos/'.$namei;}
$image_dimensions = getimagesize($file);
$height = $image_dimensions[1];
$width = $image_dimensions[0];
if ($photo=='avatar'){
if (in_array($ext, $valid){
if (($width>64) || ($height>64)){
$text='Image dimensions are too big';
header('Location: index.php?i=avatar');
}else{
if(copy($file, $path))
{
mysql_query("UPDATE `users` SET avatar='".$path."' WHERE id='".$_SESSION['id']."'");
header('Location: index.php?i=usrinfo&id='.$_SESSION["id"].'');
}
else{
header('Location: index.php?i=avatar');
}
}
else{
header('Location: index.php?i=avatar');
}
}
}
if ($photo=='photo'){
if (in_array($ext, $valid){
if (($width>175) || ($height>200)){
header('Location: index.php?i=avatar');
}else{
if(copy($file, $path))
{
mysql_query("UPDATE `users` SET avatar='".$path."' WHERE id='".$_SESSION['id']."'");
header('Location: index.php?i=usrinfo&id='.$_SESSION["id"].'');
}
else{
header('Location: index.php?i=avatar');
}
}
else{
header('Location: index.php?i=avatar');
}
}
}
?>
And here's the form
<form action="avaup.php" method="POST" enctype="multipart/form-data"> Select a file <input type="file" name="userfile" size="18"><br> <select name='pic' class='select'> <option value='avatar'>Avatar</option> <option value='propic'>Profile picture</option> </select><br> <input type='submit' name='submit' value='Submit'> </form>When I submit the form it just gives me a blank page..so I just don't know whats wrong with it =/
Thanks, Matt.
