dqba94619 2015-08-30 12:53
浏览 254
已采纳

PHP代码mkdir()不工作,没有错误

pls i need help am trying to use the mkdir for user profile pic upload and its not working ... but when i use it normally i.e ordinarilly for example when i created a new php page and used " mkdir("newdir") "it worked

    <?php
if (isset($_FILES['profilepic'])) {

   if (((@$_FILES["profilepic"]["type"]=="image/jpeg") || 
 (@$_FILES["profilepic"]["type"]=="image/png") || (@$_FILES["profilepic"]
["type"]=="image/gif"))&&(@$_FILES["profilepic"]["size"] < 1048576)) { 
//1 Megabyte 
   $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$rand_dir_name = substr(str_shuffle($chars), 0, 15);
mkdir("userdata/profile_pics/$rand_dir_name");
}
else{

}

}
?>

<p>UPLOAD YOUR PROFILE PHOTO:</p> <br />

<form action="" method="POST" enctype="multipart/formdata">

<img src="./img/default_pic.png" width="70" />

<input type="file" name="profilepic" /><br /><br />

<input type="submit" name="uploadpic" value="Upload Photo"><br />

</form>
  • 写回答

3条回答 默认 最新

  • douzhi3105 2015-08-30 17:55
    关注

    its not because of php, the php code is written well the problem is in the html where the html form enctype is written wrong

    this

    <form action="" method="POST" enctype="multipart/formdata">
    

    should be

    <form action="" method="POST" enctype="multipart/form-data">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度