I am unable to see any image uploaded in the target folder. I also tried if (move_uploaded_file($HTTP_POST_FILES['memphoto']['tmp_name'], $target.$HTTP_POST_FILES['memphoto']['name'])) instead of if(copy($_FILES['photo']['tmp_name'], $uploadimages)) but didn't get any result. Can anybody help me.
<?php
if ((isset($_FILES['photo']) && ($_FILES['photo']['size'] > 0))
{
$typ = $_FILES['photo']['type'];
if($typ == "image/gif" || $typ == "image/png" || $typ == "image/jpeg" || $typ == "image/pgif" || $typ == "image/ppng" || $typ =="image/pjpeg" || $typ =="image/jpg")
{
$uploaddir = "images/";
$uploadimages = $uploaddir.basename($_FILES['photo']['name']);
if(copy($_FILES['photo']['tmp_name'], $uploadimages))
{
echo "File successfully copied";
$query = "UPDATE $tbl_name SET photo='$uploadimages WHERE ID='$ID' ";
if (!mysql_query($query))
{
die('Error: ' . mysql_error());
mysql_close();
}
}
else{echo "Copy unsuccessful";}
}
else{
echo "Incorrect file type";
}
}
else {
echo "No Photo/Signature file selected/uploaded.";
}
?>
$_FILES['photo']['error']
before doing anything with the uploaded file. And it is highly recommended to usemove_uploaded_file()
instead ofcopy()
. – Till Helge