2017-03-08 25 views
0

您好我有这样的PHP代码(自定义脚本)从RightNow的事件查询FileAttachment的URL,下载图像WebDAV文件夹的网址用新的名称和检索

<?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:https://host.com/cgi-bin/some.cfg/php/admin/console_util/fa_get.php?p_parms=eUofFOziR6q7tVDrMAkPfz_F0iz5Nf17TjtEH18Z72PdbM9JJq6g4VNUF4oXfPY~UpgHsJhH0Nr7KKYBg78sV69A2pcj3h1cn5_mRTSyJtQHtkwQz8bqcldb8gjEUwtfQkgPVNx3u1jHjCESYm7aXKv7v4zqVV1_f_MTJp1ooey9tMHBsFlsKw0jQjurEl15gIeFNt011UglH3ccOhCvgimvVmsMvs2HbrVymNwZ1HmMtKewDQfdCy35Oi5kgotrQHoJ3QQn10fuGTjlrjgW1MEXncdTUHx2645YZxlmraur7_mpIJzWw9Rg !!

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

回答

0

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

虽然这种方法很危险,因为您基本上在公共互联网上公开受保护的事件数据,因为资产不是受保护的文件夹。

相关问题