Remote download phpBB file

I want to be able to upload a remote file to my server via phpbb without first downloading the file to my computer. How can this be achieved?

I have a simple code that I tested and it does the job, but where can I put it and what do I need to change 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 can you use the remote avatar function in phpBB (i.e. includes / functions _upload.php -> function remote_upload ($ upload_url))? Of course, I need a remote file to send through the normal phpBB functions, which you need to insert into the database and that's it.

+8
php remote-server file-upload phpbb3
source share
1 answer

open file includes / message _parser.php

find line 1373

  $upload_file = (isset($_FILES[$form_name]) && $_FILES[$form_name]['name'] != 'none' && trim($_FILES[$form_name]['name'])) ? true : false; 

and replace with

  $upload_file = (isset($_FILES[$form_name]) && $_FILES[$form_name]['name'] != 'none' && trim($_FILES[$form_name]['name'])) ? true : (!empty($_POST['urlupload'])) ? true : false; 

open file includes / functions _posting.php

find line 414

  $file = ($local) ? $upload->local_upload($local_storage, $local_filedata) : $upload->form_upload($form_name); 

replace

  $file = ($local) ? $upload->local_upload($local_storage, $local_filedata) : (!empty($_POST['urlupload'])) ? $upload->remote_upload($_POST['urlupload']) : $upload->form_upload($form_name); 

open styles / your _style / templates / posting_attach_body.html

find

  <dl> <dt><label for="fileupload">{L_FILENAME}:</label></dt> <dd> <input type="file" name="fileupload" id="fileupload" maxlength="{FILESIZE}" value="" class="inputbox autowidth" /> <input type="submit" name="add_file" value="{L_ADD_FILE}" class="button2" onclick="upload = true;" /> </dd> </dl> 

add after

  <dl> <dt><label for="urlupload">Remote File:</label></dt> <dd> <input type="url" name="urlupload" id="urlupload" maxlength="{FILESIZE}" value="" class="inputbox autowidth" /> <input type="submit" name="add_file" value="{L_ADD_FILE}" class="button2" onclick="upload = true;" /> </dd> </dl> 

Let me know if you want me to create a mod for you to install using autod, or if you need additional mime types with the remote_upload function

test @ http: /www.damienkeitel.com

phpbb phpbb3

+4
source share

All Articles