[英]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');
?>
這將返回文件下載網址,如果在瀏覽器中打開該網址,則會自動將圖片下載到我的計算機上
我想使用此URL將事件ID和圖像ID作為名稱直接將圖像直接下載到Customer Portal文件夾“ / euf / assets / images /”,然后為該圖像構建一個新的URL並將上面的腳本重定向到該圖像URL這樣我們就可以直接在瀏覽器中看到圖像。
在位置標頭之前發送內容類型標頭,以便瀏覽器知道端點是圖像。
但是,這種方法很危險,因為您基本上是在公共Internet上公開受保護的事件數據,因為資產不是安全文件夾。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.