I am receiving data from local server backend and I want to be to load image. I am receiving array of object like this:
[ {
"t_pdno": "SFC093989",
"t_mitm": "SLS005251ACL-3382012763-1",
"t_qrdr": 60,
"Operations": "10,20,30,40,60,70",
"path": "\\\\192.168.1.245\\Images\\ACL-3382012763-1.jpg"
},
{
"t_pdno": "SFC093991",
"t_mitm": "SLS005251ACL-3382012765-1",
"t_qrdr": 120,
"Operations": "10,20,30,40",
"path": "\\\\192.168.1.245\\Images\\ACL-3382012765-1.jpg"
},]
After I console.log(rowData.path) the path it looks like this:
\\192.168.1.245\Images\ACL-3382014766-1.jpg
So it is perfect to paste in browser and I get the image:
The problem is I cannot load it in my img tag. I tried:
<img
src={process.env.PUBLIC_URL + rowData.path}
alt={`${rowData.t_mitm}`}
loading="lazy"
/>
<img
src={rowData.path}
alt={`${rowData.t_mitm}`}
loading="lazy"
/>
<img
src={require(rowData.path)}
alt={`${rowData.t_mitm}`}
loading="lazy"
/>
<img
src={`url(rowData.path)`}
alt={`${rowData.t_mitm}`}
loading="lazy"
/>
and nothing is working. How can I load the images?
UPDATE:
If I install http-server to the \\192.168.1.245 server and host the Images folder there on specific port I am able to receive the image. But this mean that I will always have to keep folder hosted.
UPDATE 2:
If I try loading the image like this:
<img
src={`file://192.168.1.245/Images/${rowData.t_mitm}`}
alt={`${rowData.t_mitm}`}
loading="lazy"
/>
It probably works but I get:
Not allowed to load local resource: file://192.168.1.245/Images/ACL-3382012763-1.jpg
To use an image on a webpage, use the <img> tag. The tag allows you to add image source, alt, width, height, etc. The src is to add the image URL. The alt is the alternate text attribute, which is text that is visible when the image fails to load.
To fix this, all you need to do is create an ASHX handler page that fetches the images that are on the server's local drive or network and serve them as an image to the browser: Show activity on this post. 1) Why the proxy page can access the physical path but other page cannot able to access it ? The other page can.
The shared folder is NOT in the INETPUB folder and it cannot be moved. The directory structure of the shared folder is similar to the following: In this scenario, the IMAGES folder is shared as "IMAGES" to Everyone and IUSR.
You need to create a virtual directory to the folder where the image is located and access using "External" option rather than "Embedded" mode. Then we can access the image using http://sitename/imagefolder/abc.jpg
But here we are going to discuss sharing files using Apache Server from your computer. Your system has to be connected to a LAN for Accessing the files from one computer to another connected on a LAN. The local server is the same as our web server. As our Web Server serves our needs anywhere and anytime.
Despite browsers supporting file://
to open local files the support ends here. It is considered a security violation to open a local file within a webpage. This is why your system is not working.
http://
Chrome
you may try --allow-file-access-from-files
and --disable-web-security
flags)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With