PDA

View Full Version : fwrite or copy - which is better for php uploading?


mjz
December 12th, 2004, 02:18
I am currently using...


copy ("$file", "/home2/free/public_html/images/$file_name") or die("Could not copy file");


...for my uploading script on http://www.free-image-host.org.

What are the pros and cons of using copy opposed to fwrite. Does it even really matter for the type of page I run? Everything seems to work like a charm.

sonicgroup
December 12th, 2004, 02:45
This is in no way authoritative. but I would think using copy would make more sense (that or rename). Because with copy or rename, you're just moving the file, but with fwrite, you cause a lot of overhead because you have to store the file in memory and then write it out to a file. This, in my opinion, also allows for a lot of potential problems with security and/or corruption of the files.