且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

php脚本点击链接更新mysql表

更新时间:2023-02-07 12:30:20

DownDir = http:// localhost / SGA-INTRANET / 跨度>

kmsroot。 /


user。 /


I'm new to php and need help.
I'm not able download a file & update the DB's log table at the same time.
For more details please, please, please see the Link.

And, My code as below:

<?php
$DownDir = "http://localhost/SGA-INTRANET/".$kmsroot. "/". $user. "/". $bu. "/". $client. "/". $project."/Final";
$filenames = "file.xlsx";

$pathDown1 = $DownDir. "/".$filenames;//download path

//using download functionality of HTML 5
echo '<a download="Final_File_'.$filenames.'" name="save" href="'.$pathDown1.'?id='.$name.'&filepath='.$pathDown1.'" target="_blank"><img src="images/Save File.png" title="Download the file"/></a>';
?>

<?php 

$ide = $_GET['id'];//EmployeeID
$file = $_GET['filepath'];// Path

if(isset($ide) && isset($file)) 
{
 if(file_exists($file)) 
  {
    //save log to DB table 'tbl_km_file_download'
    $mysqli = new mysqli("localhost", "USERNAME", "PASSWORD", "DBNAME");
    $mysqli->query("INSERT INTO `tbl_km_file_download` (`name`, `filename`) VALUES ('$ide',  '$file')");
  }
}

?>

DownDir = "http://localhost/SGA-INTRANET/".


kmsroot. "/".


user. "/".