0

我正在使用 PHP 和 Codeigniter 开发我的第一个 Facebook 应用程序。我正处于一个数组中向我提供以下信息的地步:

array(11) {
  ["urlPic"]=>
  string(94) "https://sphotos-a.xx.fbcdn.net/hphotos-ash4/s720x720/486147_10151513597963642_1435805055_n.jpg"
  ["first"]=>
  string(6) "Vinnie"
  ["last"]=>
  string(7) "Saletto"
  ["street"]=>
  string(17) "123 Main Street"
  ["city"]=>
  string(10) "Manchester"
  ["state"]=>
  string(2) "MO"
  ["zip"]=>
  string(5) "63021"
  ["plus"]=>
  string(0) ""
  ["phone"]=>
  string(12) "555-555-5555"
  ["x"]=>
  string(3) "158"
  ["y"]=>
  string(2) "38"
}

一切都很好。然后我需要做的是(在 PHP 的范围内)从值 $_POST['urlPic'] 中获取 URL 并将其下载到我的服务器上,然后使用指向我创建的新文件的链接。以前有没有人这样做过,这可能吗?如果是,请告诉我如何。请理解这是针对大型打印项目的,因此我需要从 URL 下载图像,而不是仅仅链接 URL。任何帮助将不胜感激。

4

1 回答 1

2

您可以尝试快速而肮脏file_get_contents() -> file_put_contents()地从其他服务器上获取文件-

$newFilePath = '/path/on/your/server';
$data = file_get_contents($urlPic);
file_put_contents($newFilePath,$data);

参考 -

于 2013-02-04T17:57:17.890 回答