I want to add image in directory. The directory makes dynamically. But there is an error while uploading the image in directory and image can't upload due to this error the error is given below:
Warning: mkdir(): File exists in C:\wamp\www\test\index.php on line 21
My code is here:
<body>
<form method="post" action="" enctype="multipart/form-data">
<input type="file" name="filename" id="filename" />
<input type="submit" name="pic" />
</form>
</body>
</html>
<?php
if(isset($_POST['pic'])){
$comimages = $_FILES['filename']['tmp_name'];
$targetpath = mkdir("pageimage/pageid");
$compath = $targetpath."/".$_FILES['filename']['name'];
$comFileType=$_FILES['filename']['type'];
$comFileSize=$_FILES['filename']['size'];
$comFileSize=$comFileSize/1024;
if($comFileSize<1000)
{
$arrFileType=array("image/jpeg","image/png","image/gif","image/bmp");
if(in_array($comFileType,$arrFileType))
{
move_uploaded_file($comimages,$compath);
}
else
{
echo("invalid file format");
}
}
else
{
echo("File Size Error");
}
}
?>