I have a PHP program that makes a simulation of an aircraft motion (for technical studies). It requires quite a lot of input data. Therefore it would be advantageous to be able to save that data on the clients computer and recall it when used.
Of course there is a need to save many different cases and to choose from a list to recall, but that is another story.

My question:
How do I write to and read from a clients computer?

Recommended Answers

All 7 Replies

You can't, use a database. It's that simple.

Save the client's ip (or session cookie id) on the server in the database when the entered information and the date.
When that computer visits the website again, you can poll the database and provide that data.

The database arrangement seems a little unpractical for this application (passwords, garbage collection etc).
But I suppose it is possible in PHP to make an arrangement where the client actively uploads from and downloads to a storage on his own computer (then the garbage is his own headache)?

Nope. Unless you use some brand-new browser capiabilities, or flash.
If it's just a bunch of fields, you can try to save it to a session cookie variable, or cookies, but beware that cookies are limited in size and are rather hard to manage.
You could just keep session cookies that link to the database, and the database entries can 'expire' on a cron job php script (just by checking the created_at date and seeing if it's so and so days afterwards).
You could also save it to a php disc session (look at php.net for instructions).
See http://www.developertutorials.com/tutorials/php/saving-php-session-data-database-050711/page1.html also...

Excuse me for beeing persistent; maybe I have not given enough information ...

The data has the shape of six files. They are very small, seen as computer files, but seen as figure tables to fill by hand, a couple of them could seem a bit scarey. You do not want to fill them in every time you want to repeat a simulation with some minor change ... or simulate a quite different case.
Is it really so that PHP does not provide a standard method for upload and download files?

Excuse me for beeing persistent; maybe I have not given enough information ...

The data has the shape of six files. They are very small, seen as computer files, but seen as figure tables to fill by hand, a couple of them could seem a bit scarey. You do not want to fill them in every time you want to repeat a simulation with some minor change ... or simulate a quite different case.
Is it really so that PHP does not provide a standard method for upload and download files?

If you want to save simulations for future use just use a damn database. Don't try to go against the grain when working with PHP. There are plenty of tools as your disposal for working with stuff like this. Instead of having the simulation parameters saved on the user's machine just have them saved in your database.

Thank you for your patience - I will consider your advice!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.