【问题标题】:Downloading image to webdav folder from url with new name and retrieve使用新名称从 url 将图像下载到 webdav 文件夹并检索
【发布时间】:2017-03-08 15:42:02
【问题描述】:

您好,我有这个 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');
?>

这将返回文件下载网址,如果在浏览器中打开该网址会自动将图像下载到我的电脑

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

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

【问题讨论】:

    标签: php url-redirection webdav imagedownload rightnow-crm


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-03
      相关资源
      最近更新 更多