php - Differences between copy, rename and move_uploaded_file

前端 未结 2 1875
粉色の甜心
粉色の甜心 2020-12-20 12:10

Are there differences when I use that functions? Why should I use one instead of the other one...

2条回答
  •  盖世英雄少女心
    2020-12-20 12:25

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

提交回复
热议问题