I saw an answer that said that I could use copy
to transfer the file. However I tried this, and it didn't work.
<?php
$img = $_GET["img"];
if($img){
if(strpos($image, ".jpg") != -1){
$ext = ".jpg";
} else if(strpos($image, ".png") != -1){
$ext = ".png";
} else if(strpos($image, ".gif") != -1){
$ext = ".gif";
} else {
die("Unsupported image type.");
}
$rand = rand(0, 100000);
if(copy($img, "/images/" . $rand . $ext)){ echo "/images/$rand$ext"; } else { echo "Unsupported image type."; }
} else {
echo "Unsupported image type.";
}
?>
The reason, as I found out, is because the copy
function isn't working. I set the allow_url_fopen
to on
in my php.ini
, so why isn't this working?