我想在目录中添加图像。该目录是动态生成的。但是在目录中上传图片时出现错误,由于此错误,图片无法上传,错误如下:
警告:mkdir(): 文件存在于第 21 行的 C:\wamp\www\test\index.php
我的代码在这里:
<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");
}
}
?>