CKEditor external image path - primefaces

I"m having an option to insert image inside CKEditor. For that i saved the image file in physical path inside the Server(Wildfly 10) folder and adding an img tag by using editor instance with (instance.insertHTML) option. Its working fine when the image was inside the server folder. If the image was outside the server path its not rendering in the editor as well as in the browser.
Help to store the image in external path (outside the Server path) to render the image in CKEditor as well as in the browser.
I'm using primefaces extension for CKEditor.

Your web application only has access to certain areas of the file system served from under the webapp. This is fundamental webapp security so a user couldn't browse your server's file system for example.

Related

Can I link .png images I have stored in res/mipap to html files I have stored in android_asset, so WebView shows both text and images in an html file?

I have an Android app which uses the WebView function, it opens html files inside my app from a local host that have been stored in the android_asset folder when prompted. However, the WebView function only shows the text in the html file, it does not show the images that I have linked into the code of the html document, these are stored in res/mipmap. It is important to me that my app can show both text and images when I use WebView to open the html file. It is also important that the html files and the images are stored in a place that means they will be added to the installable (so that the user does not have to be connected to the internet to use the App or move any files around themselves). Is it possible to link an image stored on a local host in something like android_asset or res/mipmap so that I can see both text and the image when I open the html file in WebView?
The link to the images that does not work is in res/mipmap, it is: img src = "file:///mipmap-hdpi/car.png" alt = "Test Image"
I made a new folder inside android_asset called imagepng. I then put the .png's in this folder (so the link to the image in the htlml file looks like ). The html file now calls the .png image from this place and I can see it on the app. I do not know yet if this makes it into the installable so it can be run locally from the
smart phone..........My original mistake was trying to put the images directly into android_asset as it does not allow this.

How can anchors <a href=""> be created without the protocol and domain?

What is the correct way to do this and have what is generated / used by the browser be relative paths?
I need to do this in order to generate PDF's with links that will open files in a folder directory on a user's hard drive. The links must use relative paths, since the files will be downloaded in a directory structure that will be moved around on the hard drive. To further clarify the use case, the PDF(s) and the files will be downloaded in zip archives together, so the initial relative location will always be known.
I understand there are things in place in browsers to prevent this working from within a browser window, but in this case it will only be used in anchors in PDF files generated from HTML.
One of the problems with using something like this is that the protocol and domain is appended to the front of the path in the anchor. The relative path that's needed is to navigate within a folder directory in Windows Expolorer.
file.txt
The PDF's are converted from HTML using SelectPdf, and this is an Asp.Net MVC web app.
I have tried variations of this, which windows explorer is not able to use:
file.txt

After hosting application Images are not displayed,css is not applied

After i hosted my HTML5 application on Apache tomcat.My page is not showing any background image.
I have placed my project folder (MyExpert) inside root folder and inside MyExpert folder there is an image folder and a css folder .I am giving background image as
background-image:url(../images/myprofile_on.png)
in my css file but images are not coming on my pages except home page.Though application is working fine on localhost.I tried various thing but no fruitful result.
it looks like it will be a simple referencing or permissions issue here, try nivgating directly to the image in your browser and see if you can navigate to it manually so is this case given your description it would be:
http://www.yourdomain.com/MyExpert/images/myprofile_on.png
If that works then its a simple referencing issue from you css file, if it returns a forbidden access page you know its permissions, if it returns a file not found I would recommend checking the casing on your CSS url to ensure it matches the file path as if your box is linux then file paths are most likely case sensitive.

Opening a Local PDF file in Browser using JSP

I have tried to open a PDF file from the local disk.
For example the Location is:
E:/files/IT/cat1/cat1Notification.pdf
But during runtime the link changes to:
http://localhost:8080/Office_Automation/E:/files/IT/cat1/cat1Notification.pdf
How to do i get rid of http://localhost:8080/Office_Automation/ from the link and open the file?
I have used
click here
To open the local file you need to use the file scheme in your URL
As you path is a Windows path E:/files/IT/cat1/cat1Notification.pdf, the link's href needs file:/// added before the your jsp's <%=path%> variable, so that the browser knows it needs to open a local file on the user's machine.
So your link should look like this
click here
Which in your browser will resolve to file:///E:/files/IT/cat1/cat1Notification.pdf
Without the file scheme the browser assumes that your link is relative to the webpage and tries to resolve the link by making a request to your webapp. This is why you were getting http://localhost:8080/Office_Automation/E:/files/IT/cat1/cat1Notification.pdf

Unusual issue with HTML image and 'file://' specified src

I'm loading an image on the page with a 'file:///some_dir/image.jpg' src path. I can access the image in a regular tab using this path. Also, saving the page as HTML and using this path for the image works. However, the image does not load on the live page. In chrome it shows part of the alt text, and in firefox it shows a narrow strip. I have tried changing width and height but to no avail. Is there something I'm missing?
<img title="Click to enlarge" src="file:///Users/Aram/uploads/profile.image.985b0f707d972bf3.4372696242656464696e67616e645465657468696e67437269625261696c436f7665722e6a7067.jpg" class="profile-image">
EDIT:
I noticed I am getting this in the console:
Not allowed to load local resource
Is there any way around this?
EDIT 2:
Since I could not access the image through an http path, I have decided to read it in as base64 data. For anyone else using web2py or another Python framework:
# Load the image data
import os
path = os.path.join(request.folder, 'uploads', filename)
data_uri = open(path, 'rb').read().encode('base64').replace('\n', '')
data = 'data:image/png;base64,%s' % data_uri
return html.IMG( _src=data, _class='profile-image', _title='Click to enlarge' )
Websites are not allowed to use local files on the user's computer. Use a relative path to from the html file's directory.
You can also encode and embed the image directly:
How to embed the encoded stuff: http://www.sweeting.org/mark/blog/2005/07/12/base64-encoded-images-embedded-in-html
Python Encoding Instructions: http://www.daniweb.com/software-development/python/code/216635
The problem is you are trying to load a file directly off of a clients computer. Browsers prevent this.
You can read about the exact details here:
http://en.wikipedia.org/wiki/Same_origin_policy
It is called the Origin Policy. It prevents malicious sites from directly loading files off of a clients computer. Try using a relative path from your page to display the image.
In some situations (rare) I've used a light web server to host the site so that I could load the files from the server (as opposed to having it load off of what the browser sees, as a clients computer).