php - phpBB remote file upload -
i want able upload remote file server through phpbb without having file downloaded pc first. how can achieved?
i have simple code have tested , job, can put , need 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 save downloaded files to. must end slash $destination_folder = 'mydownloads/'; $url = $_post['url']; $newfname = $destination_folder . basename($url); //open remote file $file = fopen($url, "rb"); if ($file) { //write 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 possible tap remote avatar function in phpbb (ie. includes/functions_upload.php -> function remote_upload($upload_url))? of course need remote file sent through usual phpbb functions inserted db , all.
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 with
$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 me create mod install automod or if need mime types remote_upload function
tested @ http:/www.damienkeitel.com
Comments
Post a Comment