Click here to Skip to main content
15,897,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
if(isset($_REQUEST['submit']))
{
$g_id=$_REQUEST['gid'];
$image_title=$_REQUEST['imgname'];
$post_image1= $_FILES['upload1']['name'];
$image_tmp1= $_FILES['upload1']['tmp_name'];
$disc=$_REQUEST['disc'];
move_uploaded_file($image_tmp1,"../images/gallery/$post_image1
$result="INSERT INTO galleryimage VALUES ('','$image_title','$post_image1','$disc','$g_id')
if(mysql_query($result))
{
echo "<script>alert('Image Added Successfully !');</script>";
echo "<script>document.location.href='add-image.php?name=$dbuser'</script>";
}
else
{
echo "<script>alert('Image Not Added Successfully. Please try again later');</script>";
echo "<script>document.location.href='add-image.php?name=$dbuser'</script>";
}
}
?>
Posted
Comments
Member 12081559 27-Nov-15 3:07am    
how to validate only image upload

1 solution

Use
PHP
$allowed =  array('gif','png' ,'jpg');
$post_image1= $_FILES['upload1']['name'];
$ext = pathinfo($post_image1, PATHINFO_EXTENSION);
if(in_array($ext,$allowed) ) {
   //Do your stuff here
}
else
{
 echo 'Image is not in jpg/png format';
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900