-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.delete.php
29 lines (23 loc) · 864 Bytes
/
.delete.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
<?php
unlink(dirname(__FILE__) . '/uploads/' . $_GET['file']);
$command = escapeshellcmd('python3 /home/pi/code/MY_API/generateID.py "' . $_GET['file'] .'"');
$output = shell_exec($command);
echo $output;
$context = stream_context_create(array(
'http' => array(
// http://www.php.net/manual/en/context.http.php
'method' => 'DELETE',
'header' => "Authorization: {$authToken}\r\n"
)
));
// Send the request
$response = file_get_contents('http://localhost:5000/photos/' . rtrim($output), FALSE, $context);
// Check for errors
if($response === FALSE){
console_log('ERROR: the file did not delete');
}
// Decode the response
$responseData = json_decode($response, TRUE);
// Print the date from the response
echo $responseData['published'];
?>