I have a div class for an image search button:
<div class="form-group">
<button onclick="myFunction()">Click me</button>
<p id="demo"></p>
<script>
var link = "https://source.unsplash.com/all/?";
var articleTitle = "<?php echo "'" . $article->title . "'"; ?>";
function myFunction() {
var d = new Date();
var c = link + articleTitle + "[" + d.getTime()+"]";
document.getElementById("demo").innerHTML = "<img src=" + c + " height='100' width='100'/>" ;
}
</script>
</div>
Each click on this button gives me a new image by my keyword ($article->title) with a unique http url.
And I want to do one more button, which will save the image founded by first button on my server. I want to use something like this:
<?php
$image = file_get_contents("c");
file_put_contents('C:\xampp\htdocs\test\htdocs\image\image.jpg', $image);
?>
Where "c" is my link from first button.
So the question is: What should I change here: file_get_contents("c");
as I want place my url from first button into file_get_contents
, because file_get_contents("c");
this method didnt work.