$file_url = 'https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg';
$tmp_file = download_url( $file_url );
echo '<pre>';
print_r($tmp_file);
echo '</pre>';
// Sets file final destination.
$filepath = ABSPATH . '/wp-content/uploads/downloaded-file-test.jpg';
// Copies the file to the final destination and deletes temporary file.
copy( $tmp_file, $filepath );
@unlink( $tmp_file );
0 Comments
Post a Comment