Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
965 views
in Technique[技术] by (71.8m points)

file upload - php - Differences between copy, rename and move_uploaded_file

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
  • 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...