开发者

how does the php copy function destination string ( ./ )work?

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 sai开发者_如何转开发d 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.


./ 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜