-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I want to store all images in a centralized directory that is outside my application, including the possibility of a different drive.
I am dynamically creating the file URL based on a configuration setting concatenated with the image to display. I know this code works based on the fact that if I set the path to my images relative to the application all is well, however when I set the path to the image outside of the application the image is never displayed. 1. the external path is correctly pointing to the right directory and is read from the configuration entry correctly. 2. the image file with extension is identified in the code correctly and is physically where the external path is pointing to. 3. The O/S is Win 7 and there are no permission errors for accessing the file. 4. there are no errors or exceptions thrown
what works: background-image: url('../myapp/images/foo.png');
what does not work: background-image: url('e:/myapp/images/foo.png'); background-image: url('e:\myapp\images\foo.png'); background-image: url('e:\myapp\images\foo.png'); background-image: url("e:"+File.separator+"myapp"+... you get the idea I hope
when I use Chrome to inspect the field I see background-image: url(file:///e:/myapp/images/foo.png); <-- in other words, file:/// pre-appended to my entries above.
I noticed a similar question in these forums: http://forum.zkoss.org/question/92875/background-image-path-to-external-url/
though in that case they are going to an external http location and I am going to an external, reachable file location.
The comment by Chill does not directly answer the issue that we both seem to be experiencing: file locations outside the applications relative path do not seem to work, or we are doing something wrong to get to the path.
thanks for your help Cosmic
Hi Clueless,
The comment I placed was to point out a bad practice, that's why it's a comment and no answer. If you don't do the bad practice you don't have that problem.
If you still sure you want it like that, then you should watch this fiddle created for you.
Create c:/test.jpg.
Run this fiddle.
That requirment is logic, you have to save it to a fileshare somewhere.
Hope that this can help you out.
Greetz chill.
thank you for your response. As my post indicates, it is the external file location that is giving me trouble, have you ever tried or had success using file:///?
FYI, I am deploying an application that allows customers to upload their own images in a clustered environment. We have a drive that swings with the active cluster. Having an external drive, separate from the application, makes practical sense to me.
Asked: 2014-07-28 17:14:02 +0800
Seen: 19 times
Last updated: Jul 29 '14