php - Differences between copy, rename and move_uploaded_file

倾然丶 夕夏残阳落幕 提交于 2019-11-29 13:29:21
  • copy() copies the file - you now have 2 files, and for large files, this can take very long
  • rename() changes the file's name, which can mean moving it between directories.
  • move_uploaded_file() is basically the same as rename(), but it will only work on files that have been uploaded via PHP's upload mechanism. This is a security feature that prevents users from tricking your script into showing them security-relevant data.

In the future, I suggest looking up such information in the PHP Manual yourself.

ITroubs

I found this in the manual of move_uploaded_file():

Florian S. in H. an der E. [.de] at 17-Aug-2008 09:02

move_uploaded_file (on my setup) always makes files 0600 (rw- --- ---) and owned by the user running the webserver (owner AND group). Even though the directory has a sticky bit set to the group permissions! I couldn't find any settings to change this via php.ini or even using umask().

I want my regular user on the server to be able to tar cjf the directory .. which would fail on files totally owned by the webserver-process-user; the copy(from, to) function obeys the sticky-bit though!

so it seems like copy and rename do a slightly different work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!