After remotely downloading a file from another server without storing it on the hard disk, you can directly upload it to another server. how can this problem be solved?

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.