Enter Keyword Hear for Search This Blog

Showing posts with label how to only image upload in database using php. Show all posts
Showing posts with label how to only image upload in database using php. Show all posts

Saturday, 23 April 2016

how to only image upload in database using php

form.php

<html>
<body>
<form action="form_pro.php"method="post"enctype="multipart/form-data">
<h1>Image:</h1>
<input type="file"name="img"/>
<br/><br/>
<input type="submit"value="upload"/>
</form>
</body>
</html>

form_pro.php

<?php
if(empty($_FILES['img']['name']))
{
echo "Please select image";
}
else
{
$ext=strtolower(substr($_FILES['img']['name'],-4));
if(!($ext==".jpg" || $ext=="jpeg" || $ext==".png" || $ext==".gif"))
{
echo "Wrong File";
}
else

{
$fname=time().$_FILES['img']['name'];
$fname=str_replace(" ","_",$fname);
move_uploaded_file($_FILES['img']['tmp_name'],"cbr/".$_FILES['img']['name']);
{
echo "Image Selected";
}
}
}
?>

Featured post

what is ajax?how to create ajax with php code

Ajax Introduction -  એજેક્સ નો ઉપીયોગ કરી ને તમે પેજ લોડ કાર્ય વિના બધી માહિતી મેળવી શકો.એજેક્સ થી તમે કોઈ પણ ડેટા ઝડપ થી મેળવી શકો છો...