'Fetching' file's content over Internet (not download it)

Get help using Construct 2

Post » Mon Feb 13, 2017 8:30 am

I want to fetch files from the Internet and use them in C2.
Example:
A File ~ "file.txt" from "http://example.com/folder/file.txt" and use the file's content under C2 :?

For an instance:
A file named "users.txt" containing: "hello, world, test", fetching them from C2 somehow and using the fetched value as string

Any possible ways?
(Extra: I'm using Release 212 of C2) Thanks :roll:
B
5
S
1
Posts: 10
Reputation: 345

Post » Mon Feb 13, 2017 9:13 am

HackerBoy wrote:: I'm using Release 212 of C2


I can't see any reason why anyone would still be using a version from 2.5 years ago. There have been many, many changes to C2 since then. It is not feasible to try and support such an old version.

Please upgrade to at least the latest stable release (link at bottom of forum) or it's likely that users giving you examples will not work.

Thanks
If your vision so exceeds your ability, then look to something closer.
Moderator
B
131
S
29
G
81
Posts: 5,328
Reputation: 56,630

Post » Mon Feb 13, 2017 5:47 pm

Ajax: https://www.scirra.com/manual/107/ajax

BTW, you should consider @zenox98 advice.
Lead developer at Octeto Studios

Visit our portfolio at: http://www.octetostudios.com/ :)

Facebook || Twitter || Youtube
B
37
S
7
G
5
Posts: 217
Reputation: 5,614

Post » Tue Feb 14, 2017 9:19 am

Roger! BTW Thnx :)
B
5
S
1
Posts: 10
Reputation: 345

Post » Tue Feb 14, 2017 9:51 am

helpful for me
B
1
Posts: 1
Reputation: 127

Post » Tue Feb 14, 2017 10:29 am

Any way to get the server's response from C2? (like PHP file 'echoes' something?)
B
5
S
1
Posts: 10
Reputation: 345

Post » Tue Feb 14, 2017 3:00 pm

HackerBoy wrote:Any way to get the server's response from C2? (like PHP file 'echoes' something?)


AJAX too.
If you do a GET/POST to a PHP page like this:
echo 0;

You'll have access to that "0" with AJAX.LastData
Lead developer at Octeto Studios

Visit our portfolio at: http://www.octetostudios.com/ :)

Facebook || Twitter || Youtube
B
37
S
7
G
5
Posts: 217
Reputation: 5,614

Post » Tue Feb 14, 2017 4:28 pm

Message: HackerBoy can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
I did it but still triggers the 'On Error' section everytime
http://imgur.com/a/f1fY5
Any help? (Updated C2)
B
5
S
1
Posts: 10
Reputation: 345

Post » Tue Feb 14, 2017 6:01 pm

HackerBoy wrote:I did it but still triggers the 'On Error' section everytime
http://imgur.com/a/f1fY5
Any help? (Updated C2)


1. Are you doing a POST to a GET URL?. Maybe that's your problem. You should see your web server logs.
2. Use IP instead of localhost
3. In your php file add this as the first line (after <?php): header('Access-Control-Allow-Origin: *');
4. Print as debug AJAX.LastData even in the "On any error" event.
Last edited by GamerGon on Tue Feb 14, 2017 7:47 pm, edited 2 times in total.
Lead developer at Octeto Studios

Visit our portfolio at: http://www.octetostudios.com/ :)

Facebook || Twitter || Youtube
B
37
S
7
G
5
Posts: 217
Reputation: 5,614

Post » Tue Feb 14, 2017 7:15 pm

Maybe attaching a simple .capx might help others to see what you have done and maybe see what needs to be done.

It's usually the quickest way to get a successful resolution to your problem.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
131
S
29
G
81
Posts: 5,328
Reputation: 56,630

Next

Return to How do I....?

Who is online

Users browsing this forum: ivanski1983 and 14 guests