Code: Select all
<?php
include 'opendb.php';
if(isset($_POST['upload']) && $_FILES['userfile']['size'] > 0)
{
$filetype = $_FILES['userfile']['type'];
$userID = $_POST['userID'];
$target_path = "uploads/";
$image_type = basename($_FILES['userfile']['type']);
if ($image_type == 'jpeg')
{
$image_type = 'jpg';
}
$target_path = $target_path.$userID.'.'.$image_type;
$possiblefiletypes = array('image/jpg','image/jpeg', 'image/gif', 'image/png');
if (!in_array($filetype, $possiblefiletypes))
{
echo'<b><font color=#FF0000>Sorry, this file type is not supported.</b></font>';
}
else
{
if(move_uploaded_file($_FILES['userfile']['tmp_name'], $target_path))
{
echo 'The file '.basename( $_FILES['userfile']['name']).' has been uploaded.<br>';
$query = "UPDATE js_resume SET image_type = '$filetype' WHERE userID = '$userID'";
mysql_query($query) or die(mysql_error());
}
else
{
echo 'There was an error uploading the file!<br><br>';
}
}
}
include 'closedb.php';
?>
I keep getting "Sorry, this file type is not supported." for my jpg images?!?
what is wrong with this code or am I missing something?
Thanks in advance,
Batoe