How to create file locker php software?

Asked By 40 points N/A Posted on -
qa-featured

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.

SHARE
Answered By 0 points N/A #187160

How to create file locker php software?

qa-featured

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";
    }
?>
 

 

Related Questions