What you need is "application" level locking. What you do is you create a table (or just add some fields to your present table) to track files as being "checked out" by individual users. Look at how some of the phpwiki packages do it if you need an example. What you do is something along the lines:
alter table content add checkout timestamp;
Note that in MySQL timestamp may or may not be some kind of autoupdating abomination, based on what version you're running and how you define it. In all other databases it's the same as MySQL's datetime type. Substitute that if you're on an old version of MySQL...
Anyway, after that, when someone "checks out" a file to edit, put a timestamp in that field of either the current time and have an offset of how long a user lock can last, or the time the user lock will expire.
Until the checkout times out, attempts to check out the file will fail, and afterwards, the new attempt passes, and the old edit session will not be allowed to be put in the database if someone else has checked out the file since the lock expired.