diff --git a/appinfo/routes.php b/appinfo/routes.php new file mode 100644 index 0000000..326e20e --- /dev/null +++ b/appinfo/routes.php @@ -0,0 +1,7 @@ + [ + ['name' => 'page#main', 'url' => '/', 'verb' => 'GET'], + ['name' => 'file#upload', 'url' => '/upload', 'verb' => 'POST'] + ] +]; diff --git a/css/style.css b/css/style.css new file mode 100644 index 0000000..9087c36 --- /dev/null +++ b/css/style.css @@ -0,0 +1,14 @@ +#drop-zone { + width: 100%; + height: 200px; + border: 2px dashed #0078d4; + display: flex; + align-items: center; + justify-content: center; + color: #555; + } + #drop-zone.hover { + border-color: #005bb5; + background-color: #f0f8ff; + } + \ No newline at end of file diff --git a/lib/Controller/FileController.php b/lib/Controller/FileController.php new file mode 100644 index 0000000..829fdad --- /dev/null +++ b/lib/Controller/FileController.php @@ -0,0 +1,42 @@ +request->getUploadedFile('file'); + + // Vérifiez si le fichier a été bien reçu + if (!$uploadedFile) { + return new DataResponse(['status' => 'error', 'message' => 'No file uploaded'], 400); + } + + try { + // Sauvegardez le fichier dans le dossier de l'utilisateur + $userFolder = \OC::$server->getUserFolder(); + $userFolder->newFile($uploadedFile['name'], file_get_contents($uploadedFile['tmp_name'])); + + return new DataResponse(['status' => 'success', 'filename' => $uploadedFile['name']]); + + } catch (\Exception $e) { + // Loggez l'erreur pour plus de détails + \OC::$server->getLogger()->error("File upload error: " . $e->getMessage(), ['app' => 'webserver']); + + return new DataResponse(['status' => 'error', 'message' => 'Failed to save file'], 500); + } + } + +} diff --git a/templates/main.php b/templates/main.php new file mode 100644 index 0000000..1ffc86a --- /dev/null +++ b/templates/main.php @@ -0,0 +1,11 @@ + + +