猿问

求教~~我想把图片存在我新建的文件夹(一个变量)下面,但是没显示?哎。。。。。。。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<?php
$image  = $_FILES['mypicture'];
$imageName = $image['name'];
$tmp_name = $image['tmp_name'];
$error = $image['error'];
$dirName = $_POST['dirName'];
print_r($image);
if(is_uploaded_file($tmp_name))
{
 if(is_dir($dirName))
 {
  
    chdir($dirName);
      $path = $dirName.'/'.$imageName;
       move_uploaded_file($tmp_name,$path);
    echo "<img src='".$path."'>";   
 }
 else
 {
   mkdir($dirName,0777);
   chdir($dirName);
   $path = $dirName.'/'.$imageName;
      move_uploaded_file($tmp_name,$path);
   echo "<img src='".$path."'>";
 }
}
?>
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="mypicture" accept="image/gif , image/jpeg , image/jpg , image/png" />
上传到文件夹名称:
<input type="text" name="dirName" />
<input type="submit" name="bnt" value="上传" />
</form>
</body>
</html>

記憶的羽翼
浏览 1598回答 0
0回答
随时随地看视频慕课网APP
我要回答