It's more of a coding standards question this one. Which one is, if I can call it "better" to use in file upload handler scripts?
I know that fwrite()
and it's accompanying methods for reading and writing can do it in chunks but using move_uploaded_file()
is much more elegant and shorter code.
Thanks
Use move_uploaded_file()
. It does extra checks to ensure the user is not into any funny business. Also, using fread()
and fwrite()
copies the file, instead of moving it, which is a few orders of magnitude more costly than just moving it (which basically just changes it's name, given that the source and the destination are on the same partition).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With