I want to be able to upload a remote file to my server through phpbb without having the file downloaded to my PC first. How can this be achieved?

I have some simple code that I have tested and it does the job, but where can I put it and what do I need to modify in phpBB?

<form method="post">
    <input name="url" size="50"/>
    <input name="submit" type="submit"/>
</form>

<?php
// maximum execution time in seconds
set_time_limit(24 * 60 * 60);

if (!isset($_POST['submit'])) die();

// folder to save downloaded files to. must end with slash
$destination_folder = 'mydownloads/';

$url = $_POST['url'];
$newfname = $destination_folder . basename($url);

//Open remote file
$file = fopen($url, "rb");
if ($file) {
    //Write to local file
    $newf = fopen($newfname, "wb");
    if ($newf) {
        while (!feof($file)) {
            fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
        }
    }
}

if ($file) {
    fclose($file);
}

if ($newf) {
    fclose($newf);
}
?>

Or is it possible to tap into the remote avatar function in phpBB (ie. includes/functions_upload.php -> function remote_upload($upload_url))? I of course need the remote file to be sent through the usual phpBB functions to be inserted into the DB and all.

Edit
Report