Ok, in my website users can upload images as their profile photos and I save them as $username.jpg so all the image file names are unique. Problem is they all get saved in my root directory making everything there a big mess. So what kind of script will I be needing to automatically save all the photos in a folder called "profileimages"?
This is pretty much the code I have for the moment.
Select an image: <br/> <input type="file" name="profilepicture" size="10" />;
if ($_FILES) {
if($_FILES['profilepicture']['name']){
$name = $_FILES['profilepicture']['name'];
switch($_FILES['profilepicture']['type']){
case 'image/jpeg': $ext = 'jpg'; break;
default: $ext = ''; break;
}
if ($ext == ''){
echo '<script> alert("Your uploaded file is of the wrong file type, only jpeg image file types are accepted"); </script>';
}
if ($ext){
$profimg = "$user.$ext";
move_uploaded_file($_FILES['profilepicture']['tmp_name'], $profimg);
}
}
}