How do I save a json file on the server?

Get help using Construct 2

Post » Fri Nov 18, 2016 1:09 pm

I know how to do this on my machine but I don't know how to save it on the server. Is it possible?

Image
B
4
S
2
Posts: 136
Reputation: 874

Post » Fri Nov 18, 2016 1:53 pm

you can make a script in PHP that you will send the JSON data with the POST in AJAX, and a script in PHP that take the value and build the file .json where you want in the server...

try to find on internet "make .txt/json file in php"

this works for me very well, I don't know if there is a method to upload directly the file, I mean, save on the cache and after send the file to a specific folder, but I think is more safe with the first method
B
21
S
9
Posts: 298
Reputation: 2,967

Post » Fri Nov 18, 2016 6:13 pm

Hey @Ribis. Thanks but I what I found is very specific. Do you have an example to show me? Something that worked for you would be fine.
B
4
S
2
Posts: 136
Reputation: 874

Post » Sun Nov 20, 2016 6:17 pm

UP
B
4
S
2
Posts: 136
Reputation: 874

Post » Tue Nov 22, 2016 10:51 am

BUMP!
B
4
S
2
Posts: 136
Reputation: 874

Post » Tue Nov 22, 2016 11:00 am

$sql = "insert into `yourtablename` ('$yourtablerow) values ($yourvalues) where `yourvariable`=`yourvarisble1
The whole life is in the movement.Stopped - fell asleep to hell...
B
14
S
3
G
1
Posts: 122
Reputation: 1,694

Post » Tue Nov 22, 2016 4:04 pm

I want a text file in a json format not a db. Thanks anyway.
B
4
S
2
Posts: 136
Reputation: 874

Post » Tue Nov 22, 2016 4:25 pm

on server you need php script:
Image

Code: Select all
<?php

$name=$_POST['username'];
$txt = $_POST['data'];

$myfile = fopen($name.".txt", "w") or die("Unable to open file!");

fwrite($myfile, $txt);
fclose($myfile);
exit();
?>

************************************************

writeFilephp.capx

***********************************************

Image
Image
Image
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Wed Nov 23, 2016 3:28 pm

Hey korbaach. Thank you. You are a true life saver.
B
4
S
2
Posts: 136
Reputation: 874


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 23 guests