-
Notifications
You must be signed in to change notification settings - Fork 0
/
deleteResearchPaper.php
68 lines (59 loc) · 2.34 KB
/
deleteResearchPaper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
include("includes/header.php");
include("functions/functions.php");
include("includes/settings.php");
?>
<div class="jumbotron">
<form method="post" enctype="multipart/form-data">
<br>
<?php
coreDisplay();
?>
<div class="input-group">
<div class="input-group-btn">
<input type="file" class="filestyle" data-placeholder="No file" name="fileToDelete[]"
id="fileToDelete"
multiple="multiple">
<button class="btn btn-default pull-right" type="submit" name="deleteSubmit" value="Delete">
<i class="glyphicon glyphicon-trash"> Delete</i>
</button>
</div>
</div>
</form>
<?php
if (isset($_POST['deleteSubmit'])) {
$department = (isset($_POST['selectCore']) && $_POST['selectCore'] != '') ? $_POST['selectCore'] : '';
if (file_exists($target_dir . $department)) {
$target_dir = $target_dir . $department . "/";
echo "<div class='well well-sm'>";
$total = 0;
$items = $_FILES["fileToDelete"]["name"];
if (isset($items)) {
if ($items[0] == '') {
echo "<span class='text-danger'>Please select the files.</span>";
} else {
if (count($items) > 0)
$total = count($items);
}
}
for ($i = 0; $i < $total; $i++) {
$target_file = '';
$item = $items[$i];
if (isset($item))
$target_file = $target_dir . basename($item);
if (file_exists($target_file)) {
unlink($target_file);
$list = exec("python ./pyCalculation/deleteResearchPaper.py $item $department");
echo "<span class='text-success'>File $item has been deleted.</span>";
}
}
echo "</div>";
}else{
echo "<span class='text-danger'>File doesn't exist.</span>";
}
}
?>
</div>
<?php
include("includes/footer.php");
?>