After the files are downloaded remotely, they are directly uploaded to another server without being saved on the hard disk. how can this problem be solved? the younger brother is working on a project and needs php to download the images remotely, upload the file to another server through ftp and download it to the hard disk. this is often done. if you use ftp to upload local files, it will also be transferred directly without going through the local hard disk. how can this problem be solved, can someone help me?
Reply to discussion (solution)
File_put_contents ('ftp: // username: password @ ftp host/filename ', file_get_contents ('http: // remote host/filename '));
$ Ftp_stream connected to the ftp server already exists. if you use file_put_contents ('ftp: // username: password @ ftp host/filename ', file_get_contents ('http: // remote host/filename '), then I need to connect to the ftp server again, which will inevitably result in a waste of resources.
I think: can I use the existing $ ftp_stream like ftp_put ($ ftp_stream, $ remote_file, $ local_file) to directly write content into a file using file_put_contents?
That is to say, is there a function similar to ftp_put ($ ftp_stream, $ remote_file, $ string?
I think you're in the dark.
Ftp extensions provide ftp_fput functions. why not use them?
$ Fp = fopen ('http: // remote host/filename ', 'RB ');
Ftp_fput ($ ftp_stream, $ remote_file, $ fp );
Well, I don't want to worry about writing code at all.