簡體   English   中英

使用新名稱從URL將圖像下載到webdav文件夾並檢索

[英]Downloading image to webdav folder from url with new name and retrieve

嗨,我有這個PHP代碼(自定義腳本),可以從RightNow事件中查詢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

我想使用此URL將事件ID和圖像ID作為名稱直接將圖像直接下載到Customer Portal文件夾“ / euf / assets / images /”,然后為該圖像構建一個新的URL並將上面的腳本重定向到該圖像URL這樣我們就可以直接在瀏覽器中看到圖像。

在位置標頭之前發送內容類型標頭,以便瀏覽器知道端點是圖像。

但是,這種方法很危險,因為您基本上是在公共Internet上公開受保護的事件數據,因為資產不是安全文件夾。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM