Seach

how to upload a image using fileupload and restric loading other contents in php

<html>
<body>
<form method="post" enctype="multipart/form-data">
<input type="file" name="file" accept="image/*" />
<input type="submit" name="save" value="save"/>
</form>
</body>
</html>
<?php
if(isset($_POST['save']))
if(!empty( $_FILES['file']['tmp_name']))
{
    echo "file name is: ".$_FILES['file']['name']."<br/>"."file type: ".$_FILES['file']['type']."<br/>"."file size: ".$_FILES['file']['size']/1024 ."kb";
    if(!file_exists("upload/".$_FILES['file']['name']))
    move_uploaded_file($_FILES['file']['tmp_name'],"upload/".$_FILES['file']['name']);
    else
    echo "<br/>".'already an image exist in the same name';
}
else
{
    echo 'file upload failed';
}
?>
note: create a upload folder in the same folder where the php file saved