Asked By
Trevor Jhon
40 points
N/A
Posted on - 11/23/2012
Hi everyone,
How to create file locker PHP software?
I want to create software that will enable to encrypt and lock a specific file folder or data automatically using PHP programming language.
Is it possible?
Can you rate the percentage of possibility?
And also explain why.
Thanks.
How to create file locker php software?
Jhon,
You can use this code below to automatically check a file to see if it has been locked and if it has not the script when ran will lock onto the specified file.
If the file cannot be locked onto the script also allows you to receive an error message telling you that the file is locked by another process and terminate.
<?php
$fp = fopen("fileyouaretryingtolock.txt", "w");
if (flock($fp, LOCK_EX | LOCK_NB)) {
echo "Lock is achieved!n";
sleep(10);
flock($fp, LOCK_UN);
} else {
print "File is locked by another process!n";
}
?>