if ( !file_exists($filename) ) { $source=file_get_contents($url); $destination=fopen($filename,"w"); fwrite($destination, $source); fclose($destination); echo "File $filename downloaded. "; } else { echo "File ALREADY EXISTS. "; }