0

您好我有这个 PHP 代码(自定义脚本)来从 RightNow Incidents 查询 FileAttachment URL,

<?php 
define("CUSTOM_SCRIPT", true);
define(DEBUG, false);
define(COMMIT, true);
ini_set('display_errors',1);
error_reporting(E_ALL ^ E_NOTICE);
$ip_dbreq = true;
require_once( get_cfg_var("doc_root")."/ConnectPHP/Connect_init.php" );
use RightNow\Connect\v1_2 as RNCPHP;
try{
    initConnectAPI('user','Pass'); 
}
catch(Exception $error) { 
    echo $error->getMessage();
}
$img_url = "";
$inc_id = 296;
$entity = RNCPHP\Incident::fetch($inc_id);
foreach($entity->FileAttachments as $fileattach) {

    $img_url = $fileattach->getAdminURL();  
}
    $img_id = 23;
    $image_location = HTMLROOT . "/euf/assets/images/integration_images/images/".$inc_id."-".$img_id.".png";
    file_put_contents($img_url, fopen( $image_location , 'r'));
    header('Location: $image_location');
?>

这将返回文件下载 url,如果在浏览器中打开它会自动将图像下载到我的计算机

URL : https://host.com/cgi-bin/some.cfg/php/admin/console_util/fa_get.php?p_parms=eUofFOziR6q7tVDrMAkPfz_F0iz5Nf17TjtEH18Z72PdbM9JJq6g4VNUF4oXfPY~UpgHsJhH0Nr7KKYBg78sV69A2pcj3h1cn5_mRTSyJtQHtkwQz8bqcldb8gjEUwtfQkgPVNx3u1jHjCESYm7aXKv7v4zqVV1_f_MTJp1ooey9tMHBsFlsKw0jQjurEl15gIeFNt011UglH3ccOhCvgimvVmsMvs2HbrVymNwZ1HmMtKewDQfdCy35Oi5kgotrQHoJ3QQn10fuGTjlrjgW1MEXncdTUHx2645YZxlmraur7_mpIJzWw9Rg !!

我想使用此 url 以事件 ID 和图像 ID 作为名称将图像直接下载到客户门户文件夹“/euf/assets/images/”,然后为该图像构建一个新 url 并将我的上述脚本重定向到该图像 url这样我们就可以直接在浏览器上看到图像。

4

1 回答 1

0

在位置标头之前发送内容类型标头,以便浏览器知道端点是图像。

但是,这种方法很危险,因为您基本上是在公共 Internet 上公开受保护的事件数据,因为资产不是安全文件夹。

于 2017-03-08T19:52:41.427 回答