简体   繁体   English

跨网络链接图像

[英]Linking images across network

I have 3 datasets of images on my PC each having more than 600 images. 我的PC上有3个图像数据集,每个数据集都有600多个图像。 I want to make a webpage which is hosted on another public server. 我要制作一个托管在其他公共服务器上的网页。 This public server allows only a limited amount of space for each user so I cannot store my datasets there. 该公共服务器仅允许每个用户有限的空间,因此我无法在此处存储数据集。 Can someone give some ideas on how can I link the dataset on the public server? 有人可以提供一些有关如何链接公共服务器上的数据集的想法吗? For example while making the webpage, let's say I need to link the 3rd image of 2nd dataset. 例如,制作网页时,假设我需要链接第二个数据集的第三个图像。 Is there any way I can put a link like "10.1.34.1:99/dataset2/3.jpg" and the image will be viewable to the reader. 有什么办法可以放置“ 10.1.34.1:99/dataset2/3.jpg”之类的链接,并且读者可以看到该图像。 Assume 10.1.34.1 is my PC's ip address and 99 is the port number. 假设10.1.34.1是我的PC的IP地址,而99是端口号。

From what I understand you have a webserver which faces the internet (lets call this "web") and this server has limited storage capacity. 据我了解,您有一台面向互联网的Web服务器(我们称其为“ Web”),并且该服务器的存储容量有限。 I'm going to assume that your other server is "local" (or in your example "10.1.34.199") and not accesible from outside 我将假设您的其他服务器是“本地”服务器(或在您的示例中为“ 10.1.34.199”),并且无法从外部访问

Step 1: host a normal http server on local so that the images can be accessed on the local intranet via 10.1.34.199/dataset2/3.jpg" . However you can't use this link directly in your web , because the internet can't access it. 第1步:在本地托管一个普通的http服务器,以便可以通过10.1.34.199/dataset2/3.jpg在本地Intranet上访问图像。”但是,您不能直接在Web中使用此链接,因为Internet可以无法访问它。

Step 2: In order to be able link the image you would need to make a php script (or equivalent) which fetches this image via code and forwards the data. 第2步:为了能够链接图像,您需要制作一个php脚本(或等效脚本),该脚本通过代码获取此图像并转发数据。

<?php
$dset = intval($_GET["dataset"]);
$imno = intval($_GET["imgno"]);
header('Content-type: image/jpeg');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost:8000/dataset".$dset."/".$imno.".jpg");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
?>                                                                 

The above script could be placed inside "web" (say img_fetch.php) and now you can freely embed the image as "imgfetch.php?dataset=2&imgno=3" and it would be visible to your users. 上面的脚本可以放在“ web”中(例如img_fetch.php),现在您可以将图像自由地嵌入为“ imgfetch.php?dataset = 2&imgno = 3”,并且您的用户可以看到。

Note that this is just a hacked workaround which should work, not a recommended permanent solution if your site is being accessed by a lot of people. 请注意,这只是一个可行的变通方法,如果许多人访问您的站点,则不建议使用永久解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM