开发者

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

开发者 https://www.devze.com 2023-03-22 07:11 出处:网络
Okay so I\'m learning about uploads and need to copy the tmp file to a specified directory so I use the copy command.

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

精彩评论

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