Question

I have 3 datasets of images on my PC each having more than 600 images. 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. Assume 10.1.34.1 is my PC's ip address and 99 is the port number.

Was it helpful?

Solution

From what I understand you have a webserver which faces the internet (lets call this "web") and this server has limited storage capacity. I'm going to assume that your other server is "local" (or in your example "10.1.34.199") and not accesible from outside

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.

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.

<?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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top