亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

File copy and delete functions

1, modify the front-end code

Add get parameters to the copy and delete buttons respectively, so that they can send the file id ( file) and action type action

微信圖片_20180303090606.png

The code is as follows:

<?php
<a href="?file=<?php echo $v['file_id'];?>&action=copy">復(fù)制</a>|
<a href="?file=<?php echo $v['file_id'];?>&action=del">刪除</a>

2, get the get parameters for copy and delete operations

First obtain the get parameter file_id in index.php, then query the file table netdisk_file, and obtain the corresponding file information that needs to be copied and deleted.

Perform the copy operation of the file copy() and delete operation unlink()

The code is as follows:

<?php
//獲取get參數(shù)
$file_id=isset($_GET['file'])?intval($_GET['file']):0;
//復(fù)制和刪除功能
$action=isset($_GET['action'])?trim($_GET['action']):"";
if($action=="del"){
//    unset();
$sql="select *from netdisk_file where file_id=$file_id";
$del_file=fetchRow($sql);
unlink($del_file['file_save']);
//刪除數(shù)據(jù)庫(kù)里的數(shù)據(jù)
$sql="delete from netdisk_file where file_id=$file_id";
if(!mysql_query($sql)){
echo '數(shù)據(jù)庫(kù)數(shù)據(jù)刪除失敗';
};
}elseif ($action=="copy"){
$sql="select *from netdisk_file where file_id=$file_id";
$copy_file=fetchRow($sql);
$filesavename=$copy_file['file_save'];
if(file_exists("$filesavename.bak")){
echo '文件名沖突,復(fù)制失敗';
}
if(!copy("$filesavename","$filesavename.bak")){
echo "復(fù)制失敗";
}else{
$file_copy_name=$copy_file["file_name"];
$file_copy_size=$copy_file["file_size"];
$file_copy_id=$copy_file["folder_id"];
$sql="insert into netdisk_file (file_name,file_save,file_size,file_time,folder_id) values('$file_copy_name.bak','$filesavename.bak',$file_copy_size,now(),$file_copy_id)";
if(!mysql_query($sql)){
unlink($uploadfile_save);
echo "寫(xiě)入數(shù)據(jù)庫(kù)出錯(cuò)";
}
}
}

3, effect display

Copy display:

Click the page before copying:

微信圖片_20180303091313.png

Click to finish After copying:

微信圖片_20180303091315.png

Changes in the database:

微信圖片_20180303091319.png

Delete display:

Page before deletion:

微信圖片_20180303091640.png

Page after deletion:

微信圖片_20180303091643.png

##Corresponding database Changes have also occurred

Continuing Learning
||
<?php echo "刪除復(fù)制操作";
submitReset Code