Possible ? Can PHP write a File on the Clients Hard Disk?
Moderator: General Moderators
Possible ? Can PHP write a File on the Clients Hard Disk?
Following Problem :
I have a project on the client Sides(c++) that queries my database. I do this by the Libcurl Library biy sending a URL with POST. So far So good . Now I need the Result of the query back in my C++ Application. Is it possible that PHP Writes the Result of the Query in een Textfile direct on the clients Hard-Disk ?
I have a project on the client Sides(c++) that queries my database. I do this by the Libcurl Library biy sending a URL with POST. So far So good . Now I need the Result of the query back in my C++ Application. Is it possible that PHP Writes the Result of the Query in een Textfile direct on the clients Hard-Disk ?
well basically what you need to do is have your c++ program look for commands everytime it contacts php.
obviously you already have some way to communicate
w/ and fetch data from php, so its just a matter of
deciding what you want to be the signal for the c++ prog to identify as php telling it to save.
like for example, i assume your sending a command to php,
and then php interprets that command and queries the database, and then
php returns the result to the c++ program. you basically just need to make this works both ways
a simple way could be to have c++ check if the response contained a header called "X-Save"
so in php, if php decides its time for the client to save, it would do
and your c++ prog just checks for the existance of that header everytime it talks w/ php.
if it can find that header in the response from php, then it saves the file.
you dont need to use headers to do this, i was just giving an example
obviously you already have some way to communicate
w/ and fetch data from php, so its just a matter of
deciding what you want to be the signal for the c++ prog to identify as php telling it to save.
like for example, i assume your sending a command to php,
and then php interprets that command and queries the database, and then
php returns the result to the c++ program. you basically just need to make this works both ways
a simple way could be to have c++ check if the response contained a header called "X-Save"
so in php, if php decides its time for the client to save, it would do
Code: Select all
header('X-Save: true');if it can find that header in the response from php, then it saves the file.
you dont need to use headers to do this, i was just giving an example
Thanks a lot! What you mean I think is : C++ -> PHP -> Query DB-> PHP Writes results in file on server -> PHP Sends message to c++ -> C++ Downloads the File from Server ?
Is it possible to let Javascript write the result of a PHP query on the Clients Hard-Disk? Because Javascript is on the clients Side ?
Is it possible to let Javascript write the result of a PHP query on the Clients Hard-Disk? Because Javascript is on the clients Side ?
i dont think javascript can do that.
imagine the security problems if js could write or read from a clients harddisk.
it maybe possible if the javascript is loaded from the client side, and not from a website, but im not sure.
but yeah, you got the idea
C++ contacts http://yoursite.org/communicator.php?qu ... a_it_wants
php fetches result from database,
if php thinks its time for the client to save the file, it sends a X_SAVE header
php outputs results of db query using echo or whatever
c++ receives response, and looks for X-save
if it finds x-save, it saves the data. otherwise it just uses the data and throws it away when its done or whatever
question though, why do you need php to decide if the client should save the file?
i would think that would be something the client or the c++ app would determine?
imagine the security problems if js could write or read from a clients harddisk.
it maybe possible if the javascript is loaded from the client side, and not from a website, but im not sure.
but yeah, you got the idea
C++ contacts http://yoursite.org/communicator.php?qu ... a_it_wants
php fetches result from database,
if php thinks its time for the client to save the file, it sends a X_SAVE header
php outputs results of db query using echo or whatever
c++ receives response, and looks for X-save
if it finds x-save, it saves the data. otherwise it just uses the data and throws it away when its done or whatever
question though, why do you need php to decide if the client should save the file?
i would think that would be something the client or the c++ app would determine?
Yes you are right. I will work in C++, with a timer. Lets Say Every 2 minutes the programm sends a request to the server to query the database. So every 2 minutes there is a file that is created. So I can theoratically download the file directly after it is created by PHP, instead waiting till PHP sends the X-SAVE. So what i mean is that I think that I don´t need the X_save command.