douye2111
douye2111
2011-07-24 03:08
浏览 24
已采纳

php复制函数目标字符串(./)如何工作?

Okay so I'm learning about uploads and need to copy the tmp file to a specified directory so I use the copy command.

I use this inside my index.php of the main directory (learningupload/ folder)

  copy($_FILES['photo']['tmp_name']['file'], './pics/'.$photoname.'.jpg');

Now I'm doing this on Xampp local host, and my uploads go to the tmp folder which is of course different from where I want the upload to go so there's

C:\xampp\tmp

C:\xampp\htdocs\learningupload\pics\

My question is this: What is this ./ inside the destination string I need to have? Doesn't it usually mean you're moving UP a directory? Why not have it '/pics' no dot? I tried that and said it couldn't open the stream. Does the dot here mean it's referring to whatever directory index.php is in? Or am I thinking ../ moves up a directory? And single dot is different?

Thanks.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douzha6055
    douzha6055 2011-07-24 03:15
    已采纳

    ./ means "current working directory". Which directory is current working one you can see with echo getcwd();

    The parent directory (the upper one) is ../

    You can change your working directory using chdir() or you can just specify the full path instead.

    点赞 评论

相关推荐