我希望能够通过PHPbb将远程文件上传到我的服务器,而无需先将文件下载到我的电脑上.怎么能实现这一目标?
我有一些简单的代码,我已经测试过,它完成了这项工作,但是我可以把它放在哪里,我需要在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); } ?>
或者是否可以在PHPBB中使用远程头像功能(即包括/ functions_upload.PHP – >功能remote_upload($upload_url))?
我当然需要通过通常的PHPBB函数发送远程文件以插入数据库和所有.
打开文件包含/ message_parser.PHP
找到第1373行
$upload_file = (isset($_FILES[$form_name]) && $_FILES[$form_name]['name'] != 'none' && trim($_FILES[$form_name]['name'])) ? true : false;
并替换为
$upload_file = (isset($_FILES[$form_name]) && $_FILES[$form_name]['name'] != 'none' && trim($_FILES[$form_name]['name'])) ? true : (!empty($_POST['urlupload'])) ? true : false;
找到414行
$file = ($local) ? $upload->local_upload($local_storage,$local_filedata) : $upload->form_upload($form_name);
用…来代替
$file = ($local) ? $upload->local_upload($local_storage,$local_filedata) : (!empty($_POST['urlupload'])) ? $upload->remote_upload($_POST['urlupload']) : $upload->form_upload($form_name);
打开样式/ your_style / templates / posting_attach_body.html
找
<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>
之后添加
<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>
如果您希望我创建一个用于使用automod进行安装的mod,或者如果您需要使用remote_upload函数的额外mime类型,请告诉我