Is this possible? – PHP



Hello, Here’s what I’m wondering how to do: I can do everything except number 3.

1) User 1 uploads a file (perhaps word doc, but not necessarily) to a predefined directory on the web server

2) user 2 opens that file by clicking on the relevant link (which he can easily see)

3) User 2 edits that file (perferably in a different colour to the standard black) and clicks some button which says "Save". The file is then saved with the changes, and then closed and put back in the same directory.

4) User 1 can then open the edited file and see the changes.

I guess it’s all essentially like sending emails with attachments back and forth, but I need it to happen on a web-based system.
Is this doable? Many many thanks to anyone who can point me in the right direction.


Yes it is doable. But you must cater to multiple formats, or restrict the upload to only one format (such as Microsoft 2003 doc format)

Instead of "editing" the document live. Why not just re-uploaded when the user makes the changes. so it’s a document sharing site. (check out open-source CMS applications)

PHP and MySQL are good if its "Data" you want to manage, and not a formatted file. For example you may want to manage a list of customers or list of something. (For example a real estate house for sale, and agents sign on add, remove, edit, and view the houses in the database)

The basic question is: is it a file (specific format) that you want to maintain or is it just pieces of data (text and numbers) ?


Hey dlite,

Thanks for replying. I think mainly it would be Word docs. The idea would be that an assessor sets a task (eg. essay), then student does the task in Word and uploads the task. Assessor then opens and edits that file, then saves it back to the server.

Obviously for the purposes of viewing only, the file could be pdf or other things, but I assume that in order to edit, it would need to be word. Am I in trouble here, or is there still hope?




Ok, in that case, I think you have two option, and they depend on your preference.

If the student/assessor doesn’t mind, you could give them a WYSIWY get editor (Google Tiny MCE) that gives them a word-like interface within a browser.

Then you basically save this information to the database. Add all the schmatics (like have the student "Save" but not "publish" so that he can do the work half way, save it, then come back and finish it, then when he publishes it, (status changes), the teacher can see it.

You can do neat stuff as far as grouping and organizing the instructor side. Having the student see their previous work, the comment made by the teacher and the grade they got. etc.

The other method is just store the word document on your server, or in a BLOB in a MySQL database. Each time an assessor or students needs to view or edit the file, they have to download it, edit it/view it, and upload it back up (over-writing the original or not if you want to keep multiple versions)

Downside to first option: More Code, student /assessor might complain as its a new interface they haven’t worked with and takes getting use to.

Downside to second option: Less interactivity/flexibility. More stress on server so its not good for high traffic applications.

Those are my suggestions based on what I know of your intentions.

Good luck,




Given what you’ve said, I think I prefer the 2nd option, mainly because it’s just less of a learning curve/stubmling block to prospective users. But also because it seems to be much "cleaner" re the coding. I agree it’s probably a little less flexible, but I’ll live with that.

So, my questions

1) Is there any general preference for storing a word doc (for instance) on the server or in a mysql db as BLOB? Will either of the two methods be quicker or slower in retrieval?

2) If I store the word doc as a BLOB, rather than on the server, will it be somehow easier for users to "save" the edited file back to the db?

3) Say the student uploads the task with a filename, eg. myfile.doc
Then the assessor opens, edits and saves to his or her local drive, in order to then upload that changed file back to the server, is there any way of *automatically* adding a timestamp to the name of the file, so it becomes myfile_20081125_1825.doc
And then when the student looks at the edited version, and perhaps makes changes and re-uploads half an hour later, the student clicks "Save As…" and the file is automatically named myfile_20081125_1855.doc?
This would have the double benefit of tracking changes in students work, and also not overwriting the original file. Server space shouldn’t be an issue.

I really appreciate your help with this one,




I"d use a BLOB for high traffic sites. But working with files that are saved on the server (each student has its own folder) could be much easier for a beginner.

2. I wouldn’t be any easier from their perspective, they don’t see a difference in use. It’s just where PHP takes the file.

3. It is possible to save the file. Just add the date/time to the end of the file (before the extension) PHP has many string functions such as explode() that could come in handy for doing this.

As far as serving as version tracking, many people will be confused to see their file name now changed to something else.

I think if your application is not simple, i’d still use a database but store the file on server. What you can do is save the "name" of the file in the database, along with other information you might collect such as the date the file was uploaded, last modified date, size, owner, and permissions.

Permissions is another whole new animal. What you could do is provide an interface for users to see the files and "lock" them. Once locked, other users can’t over-write (re-upload) a file. until the user who locked it unlocks it.

I’d worry about that later. take Baby Steps.

Good night, going to sleep.

you can IM me at <email removed> later if you have any questions.


Dan, I have removed your email. No hard feelings, it’s just against the forum guidelines to post emails. Also, please keep the discussions in the forum – a user might have the same problem, find this post, but then see there is no solution. So, even if you do discuss it further (through PM, preferably), please post the solution here.