dsc80135
2019-06-08 10:24
浏览 70

move_uploaded_file在循环中不起作用

My code is:

for($i = 0; $i < count($_FILES['creative']['name']['icon']); $i++) {
    $name = mt_rand(0, time());
    move_uploaded_file($_FILES['creative']['tmp_name']['icon'] 
    [$i],'creatives/'.$name.'.png');
    move_uploaded_file($_FILES['creative']['tmp_name']['image'] 
    [$i],'creatives/'.$name.'.png');
}

The problem is that in this code only the last move_uploaded_file works and uploads an image.

Can you explain me why the first move_uploaded_file does not work?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douhao2153 2019-06-08 12:50

    You must set another name for image file. In your code you set the $name for both icon and image.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题