0

A user will upload an index.html file and a few images, that will be sent out as an HTML email. I am working on preview functionality, so they can check before sending.

I am running into the "Not allowed to load local resource" error in Chrome, when trying to access the uploaded files.

I am running my application on JBoss 7.1. Currently my server is running locally on my laptop, could this be the problem?

I have tried using the JBoss temp folder, but I get the same error.

I thought of copying the files temporarily into a folder within the WAR archive, but I have not been able to find a way to do this.

Is there a workaround or solution to this? Or is there a way to display a MimeMultipart object in a window?

JBotha
  • 42
  • 1
  • 3
  • 9

2 Answers2

2

If your page is served from a webserver you can not use local files resource because of security reasons.

You should upload that you want to access to webserver and use relative path from the page.

So in short you have to use http:// to access the file not file:///.

j0k
  • 22,600
  • 28
  • 79
  • 90
0

Using Jboss 8.1 Wildfly, I have found an alternate solution to this problem.

Adding an additional file handler to standalone.xml does the trick.

<server name="default-server">
    <http-listener name="default" socket-binding="http"/>
    <host name="default-host" alias="localhost">
        <location name="/" handler="welcome-content"/>
        <location name="/img" handler="images"/>
    </host>
</server>
<handlers>
    <file name="welcome-content" path="${jboss.home.dir}/welcome-content" directory-listing="true"/>
    <file name="images" path="/var/images" directory-listing="true"/>
</handlers>

Thanks to hwellman's reply on the following question

Community
  • 1
  • 1
JBotha
  • 42
  • 1
  • 3
  • 9