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";
}
}
}
?>
<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";
}
}
}
?>