0

I am in the process of developing my first Facebook application with PHP and Codeigniter. I am at a point where I have the following information provided to me in an array:

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"
}

All is well and good. What I need to do is then (within the confines of PHP) take the URL from the value $_POST['urlPic'] and download it on to my server, and then utilize the link to the new file I have created. Has anyone done this before, and is this possible? If it is, please show me how. Please understand that this is for a large print project, and because of this I am in need of downloading the image from the URL as opposed to just linking the URL. Any help would be greatly appreciated.

1

1 Answer 1

2

You could try a quick and dirty file_get_contents() -> file_put_contents() to grab a file off a different server -

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

References -

Sign up to request clarification or add additional context in comments.

2 Comments

Checking into it now! Be right back, wish me luck!
YOU, Lix, are a wonderful individual! Thank you! This works perfectly!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.