Download trash.php from Urban-Guy/Drive: direct link, hf CLI and curl.
- Browser
- Download file 854 Bytes
-
https://huggingface.co/spaces/Urban-Guy/Drive/resolve/main/trash.php
- Command line
-
hf download hf://spaces/Urban-Guy/Drive/trash.php
-
curl -L -o trash.php https://huggingface.co/spaces/Urban-Guy/Drive/resolve/main/trash.php
854 Bytes
| session_start(); | |
| $metadataFile = 'data/files.json'; | |
| function loadMetadata() { | |
| global $metadataFile; | |
| if (!file_exists($metadataFile)) return ['files' => []]; | |
| return json_decode(file_get_contents($metadataFile), true); | |
| } | |
| function saveMetadata($metadata) { | |
| global $metadataFile; | |
| file_put_contents($metadataFile, json_encode($metadata, JSON_PRETTY_PRINT)); | |
| } | |
| if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['fileId'])) { | |
| $fileId = $_POST['fileId']; | |
| $metadata = loadMetadata(); | |
| foreach ($metadata['files'] as &$file) { | |
| if ($file['id'] === $fileId) { | |
| $file['trashed'] = true; | |
| $file['trashedDate'] = time(); | |
| saveMetadata($metadata); | |
| echo json_encode(['success' => true]); | |
| exit; | |
| } | |
| } | |
| echo json_encode(['success' => false]); | |
| } | |