Load XML files per AJAX request from local drive

Get help using Construct 2

Post » Wed Jul 25, 2012 5:25 pm

Hello there,

Is there any workaround to request an XML-file from local drive?

Example:
paste file path into TextBox: C:\XML_Files\some.xml
- on click OK button
-> AJAX request url (TextBox.text)
- AJAX on completed
-> Load XML document from string AJAX.LastData

I tried the above example, it doesn't work - so may be there's some workaround for that. Request from file folder and pasting XML as string will not do in this case.
B
42
S
11
G
4
Posts: 505
Reputation: 7,267

Post » Wed Jul 25, 2012 5:45 pm

it would be somethin like "file:///C:/filelocation" to open a local file in the browser. No idea if itd actually work tho
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

Post » Wed Jul 25, 2012 11:51 pm

Nope, it doesn't work like this either.
B
42
S
11
G
4
Posts: 505
Reputation: 7,267

Post » Thu Jul 26, 2012 12:00 am

JavaScript's access to the file system on the client side is restricted for security reasons. Apparently you can disable this security manually in the browser, but I'd say that's generally not a good idea, and would obviously only work on your system.

If you want to try though:
In Chrome you can run the executable with "--disabled-web-security" or "allow-file-access-from-files" as a commandline argument, Firefox can disable it within it's about:config.Nimtrix2012-07-26 00:02:59
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Thu Jul 26, 2012 9:23 am

Thanks for your help, I tried running executable with this commands, but no with effect. It seems to load something (AJAX "on completed" fires an action), but XML object doesn't load the file. I think I will just paste XML content into the textbox and load it directly into xml object without AJAX call.   
B
42
S
11
G
4
Posts: 505
Reputation: 7,267

Post » Wed Aug 22, 2012 4:36 am

I'm trying to access XML files too from a local webserver but I can't.
I can whoever access php files if I declare a access header to the file but I have no idea how to do that with .XML files

any solution??
B
30
S
6
G
5
Posts: 433
Reputation: 6,061

Post » Wed Aug 22, 2012 1:12 pm

You cannot load files from disk, because imagine the security nightmare if you could visit a web page and it could read your local files!

Instead, import any files you want to use as project files, and AJAX request them. See Using project files in Construct 2.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630


Return to How do I....?

Who is online

Users browsing this forum: Zebbi and 24 guests