简体   繁体   English

PHP copy()方法与来自远程服务器的图像文件的可靠性

[英]Reliability of PHP copy() method with image file from remote server

http://php.net/manual/en/function.copy.php http://php.net/manual/zh/function.copy.php

Makes a copy of the file source to dest. 将文件源的副本复制到dest。

After conduction several tests, the PHP copy() method works fine to copy an image file from a remote server. 经过几次测试后,PHP copy()方法可以很好地从远程服务器复制图像文件。 The image file is coped from the public html directory on the remote server, where the website images exist. 该图像文件是从存在网站图像的远程服务器上的公共html目录中复制的。

Would this method be reliable in all cases? 这种方法在所有情况下都可靠吗? In other words, are there any known configurations that may exist on the remote server that would cause copy() to fail. 换句话说,远程服务器上是否存在任何可能导致copy()失败的已知配置。

<?php copy("http://domain.com/images/file.jpg", "/local_dir/file.jpg"); ?>

cURL has been suggested but seems like overkill to perform a simple copy operation. 已经建议使用cURL,但执行简单的复制操作似乎有些过头。

如果图像不可读,则可能会失败,但是由于您说的是公众可以访问的图像,因此这不是问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM