Skip to content

Instantly share code, notes, and snippets.

@shohag-cse-knu
Created December 17, 2024 09:15
Show Gist options
  • Save shohag-cse-knu/78e475f7edd2f46dea64a1c8aaab14b1 to your computer and use it in GitHub Desktop.
Save shohag-cse-knu/78e475f7edd2f46dea64a1c8aaab14b1 to your computer and use it in GitHub Desktop.
File is tempered or not in the server storage can be checked compared to the uploading time and file modification time
<?php
$Msg = "";
$row = $this->db->query("SELECT folder_name, file_name, uploaded_time FROM documents")->row();
$folder_name = $row->folder_name;
$filename = $row->file_name;
$uploaded_time = $row->uploaded_time;
$file_path = getcwd().DIRECTORY_SEPARATOR.$folder_name.'/'.$filename;
if (file_exists($file_path)) {
$file_modification_time = date("Y-m-d H:i:s", filemtime("$file_path"));
if(strtotime($file_modification_time) != strtotime($uploaded_time))
$Msg = "FIle Tempered";
else
$Msg = "File Missing";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment