I am trying to read large files lets say illustrator file or photoshop file using cron job in my system.
Files size varies from 20 mb – 300 mb
I have been using some function but it break in middle while reading. So i wanted to have a fresh opinion.
Amount these function
- file_get_contents
- readfile
- curl
which is most effective in terms of
- consistency (should not break while reading file)
- speed
- resource uses
if there is more then two cron job, does it impact over all server performance.
Please share best practice code.
Thanks in advance
Use cURL. The file functions have been deprecated in favor of cURL to open remote files. It’s not only faster, but also more reliable1 (you are less likely to experience timeouts).
If your script times out or runs out of memory anyways, you’ll want to increase the execution time and memory limits (
max_execution_timeandmemory_limit).Other notes:
readfile()reads a file and prints it to the output buffer; it’s no the same thing asfile_get_contents().--with-curlwrappersthen when you dofile_get_contents()it will use cURL instead of thefopen()functions.1 Citation needed.