471,316 Members | 1,563 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,316 software developers and data experts.

security error accessing a file

hi all.
I have a script that tries to open a file that is on a different folder than
the one in which i am working.
that is the script:

openmydoc= "file://///192.168.1.1/web/" + type+ "/" + year+ "/" + Month+
"/myfile.xyz" ;
open(openmydoc);
the proble is that on the javascript console i have a message that alerts me
about a security error.
it says "content at http://192.168.1.1/myfldr/mydoc.htm may not load or link
to file:///// 192.168.1.1/web/..."
but if I try to open my link writing by hand the address
file://///192.168.1.1/web/... it works.
the server is apache.
any idea about how to handle this?
tia.
Jul 23 '05 #1
5 2052
ilKaos wrote:
hi all.
I have a script that tries to open a file that is on a different folder
than the one in which i am working.
that is the script:

openmydoc= "file://///192.168.1.1/web/" + type+ "/" + year+ "/" + Month+
"/myfile.xyz" ;
open(openmydoc);
the proble is that on the javascript console i have a message that alerts
me about a security error.
it says "content at http://192.168.1.1/myfldr/mydoc.htm may not load or
link to file:///// 192.168.1.1/web/..."
but if I try to open my link writing by hand the address
file://///192.168.1.1/web/... it works.
the server is apache.
any idea about how to handle this?
tia.

Hi,

The first argument for window.open (url, target, etc.etc..)
is url.

A URL starts with http://
NOT with file://

You feed something different. (a file on a share somewhere)
What do you expect Javascript to do excactly?
(Javascript cannot open files on a filesystem.)

If the file://///192.168.1.1/web/etcetc is also reachable via http, I
suggest you use that route.

SO if the content of your share is also reachable via a webserver, figure
out the URL, and use that.

Regards,
Erwin Moller
Jul 23 '05 #2
>
Hi,

first of all, thanks for your kind answer.

The first argument for window.open (url, target, etc.etc..)
is url.

A URL starts with http://
NOT with file://
i thought it could work even with file...my mistake.
You feed something different. (a file on a share somewhere)
What do you expect Javascript to do excactly?
(Javascript cannot open files on a filesystem.)
that (of course) is just what i need...

If the file://///192.168.1.1/web/etcetc is also reachable via http, I
suggest you use that route.
SO if the content of your share is also reachable via a webserver, figure
out the URL, and use that.

Regards,
Erwin Moller

you mean by having somethnig like http://192.168.1.1/web/etc/mtyfile.xyz?
it works, but the problem is that it does not open the file with the
appropriate plugin but rather tries to
open it with the browser itself. this does not happen if i refer to the file
with file://///192.168...

maybe i should specify something at the "apache level" to make the browser
capable of understanding to open
the file with the appropriate plugin? something like mim type
xyz/use_my_plugin ?

thanks again.
Jul 23 '05 #3
ilKaos wrote:

Hi,

first of all, thanks for your kind answer.


You are welcome. :-)
The first argument for window.open (url, target, etc.etc..)
is url.

A URL starts with http://
NOT with file://
i thought it could work even with file...my mistake.


The fact that a browser (sometimes) opens a file for you (when you point to
it by just typing the location into the URL) probably mislead you in
thinking that that is a normal procedure.
(But it is not)
You feed something different. (a file on a share somewhere)
What do you expect Javascript to do excactly?
(Javascript cannot open files on a filesystem.)
that (of course) is just what i need...

If the file://///192.168.1.1/web/etcetc is also reachable via http, I
suggest you use that route.

SO if the content of your share is also reachable via a webserver, figure
out the URL, and use that.

Regards,
Erwin Moller

you mean by having somethnig like http://192.168.1.1/web/etc/mtyfile.xyz?


yes.
it works, but the problem is that it does not open the file with the
appropriate plugin but rather tries to
open it with the browser itself. this does not happen if i refer to the
file with file://///192.168...

maybe i should specify something at the "apache level" to make the browser
capable of understanding to open
the file with the appropriate plugin? something like mim type
xyz/use_my_plugin ?
I don't think you have to fiddle with apache to get it done.

But I am not sure what file you are trying to load.

Try this:
1) figure out the URL http://192etcetc to the file you need in Javascript.
2) Try to feed that URL to the object/embed you are using on your page.

A simple example with an image (based on some var named month):
var myImageLocation = "http://192.168.1.1/web/"+month+"/serverload.gif";

document.images["servloadimage"].src=myImageLocation;

And somewhere in you document:
<img src="default.gif" name="servloadimage">

Try to do the same with the object/embed you are using.
If you don't know the excact syntax, google for it.
(Tip: ALso try google groups to search all the newsgroupspostings in the
past)

Good luck!

Regards,
Erwin Moller

thanks again.


Jul 23 '05 #4
Try to do the same with the object/embed you are using.
If you don't know the excact syntax, google for it.
(Tip: ALso try google groups to search all the newsgroupspostings in the
past)

Good luck!

Regards,
Erwin Moller


again, thanks a lot for your kind answer.
i will try what you suggest as soon as possible.
as you probably understood i am not deep in javascript but just using it
in some of the web pages that i am creating with cgi and iseries(as400).

the file that i need to open is an .afp (ibm print format), there is a
plugin that seem to
work only with Ie (and with the conditions i explained in the above
messages).
i am new to js but not so newbie not to try a research with google groups (i
wrote in usenet
since '96 and used deja/google groups since then).
but the problem is that not so many people seem to open afp files from a
web page, or at least they
do not seem to use the web/usenet to help poor guy like me...

hope that your suggestion will work and in any case they were important for
me to
understand some of the js concepts.
thanks and "ciao".

Jul 23 '05 #5
In article <34*************@individual.net>,
"ilkaos" <12********@katamail.it> wrote:
the file that i need to open is an .afp (ibm print format), there is a
plugin that seem to
work only with Ie (and with the conditions i explained in the above
messages).


My understanding is this:
1) you put in a link to your file <a> </a> tag. It's just like a link to
a web page except the name is different.
2) web server serves up file with the correct mime type
3) browser gets the returning file.
4) Browser decides what to do. If there is a plug in for the file, the
plug in get control. If plug in isn't there, browser decides what to do.

Robert
Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Nathan Bloom | last post: by
10 posts views Thread by Richard MSL | last post: by
3 posts views Thread by Asaf | last post: by
reply views Thread by sunoj | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.