I’m trying to save images in “bin” folder using python file library. The upload process to “bin” folder is successful, and the image (i1588240674591.jpg) is visible, but when I try to set “src” of an image tag as “./public/bin/ixxxxxxxxxxxx.jpg”, then it shows that the link is broken/invalid.
I just want to have the link for images I generate dynamically in “bin” folder. It works perfectly on localhost. Any workaround?
Also, I know, glitch provides an “assets” option. But, I want to get the link to image programmaticlly, any ideas?
BTW, my experience with glitch is most helpful so far, in deploying websites
The whole process
Okay, I’m prompting client to upload image, then I request server to store the imageurldata (like data:image/png;base64…) in a newly created jpg file, named as “i1588240674591.jpg” in our particular case. Then, when the server sends the response, JS confirms that image have been stored and it adds an image tag to document as <img src=“./i1588240674591.jpg”>.
I think I was unclear a bit. Okay, I’m prompting client to upload image, then I request server to store the imageurldata (like data:image/png;base64…) in a newly created jpg file, named as “i1588240674591.jpg” in our particular case. Then, when the server sends the response, JS confirms that image have been stored and it adds an image tag to document as . Now, you’ve suggested to remove “./”, which I think will make it absolute address? Isn’t it?
I’ve also added a comment in app
Edit: I’ve commented a pointer where the image’s final link is generated in server.py
Hey @vrintle! I’m not a Python programmer but in looking at your project, you should be able to access the /public directory from the root of the rv-blog.glitch.me site, e.g., https://rv-blog.glitch.me/bin/i1588240674591.png — so the img src would be /bin/i1588240674591.png.
That’s great! This topic is a bit more about coding than Glitch (it can be hard to tell what the issue is sometimes!), so I’m going to move it to the coding help section of the forums in case any more questions come up.