I'm using the attached code to upload an image file. The sql data is inserted correctly, and the filename is in the destination directory as expected, but the filesize is 0. Help?
if(is_uploaded_file($_FILES['form_image']['tmp_name'])) {
// file uploaded to server
$imageInfo = getimagesize($_FILES['form_image']['tmp_name']);
$width = $imageInfo[0];
$height = $imageInfo[1];
$image_type = $imageInfo[2];
move_uploaded_file($_FILES['form_image']['tmp_name'], "./pics/images/sample_dir/album_/".$_FILES['form_image']['name']);
if(isset($_POST['field1'])) {
$myfield1 = trim(htmlentities($_POST['field1']));
} else {
$myfield1 = '';
}
if(isset($_POST['myfield2'])) {
$myfield2 = trim(htmlentities($_POST['myfield2']));
} else {
$myfield2 = '';
}
$fnp = 'sample_dir/album_/'.$_FILES['form_image']['name'];
$query = "INSERT INTO pics (path, caption, description, date_submitted)
VALUES ('".$fnp."', '".$caption."', '".$description."', NOW())";
$result = $database->query($query);
if($result) {
echo 'Success!';
}
}