Add Element Document
This commit is contained in:
parent
077c144d89
commit
bf0ff5adc2
7
appinfo/routes.php
Normal file
7
appinfo/routes.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
return [
|
||||
'routes' => [
|
||||
['name' => 'page#main', 'url' => '/', 'verb' => 'GET'],
|
||||
['name' => 'file#upload', 'url' => '/upload', 'verb' => 'POST']
|
||||
]
|
||||
];
|
14
css/style.css
Normal file
14
css/style.css
Normal file
@ -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;
|
||||
}
|
||||
|
42
lib/Controller/FileController.php
Normal file
42
lib/Controller/FileController.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace OCA\WebServer\Controller;
|
||||
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Controller;
|
||||
use OCP\Files\Node;
|
||||
use OCP\IRequest;
|
||||
|
||||
class FileController extends Controller {
|
||||
public function __construct(IRequest $request) {
|
||||
parent::__construct($appName, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoCSRFRequired
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
public function upload() {
|
||||
$uploadedFile = $this->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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
11
templates/main.php
Normal file
11
templates/main.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
script('webserver', 'dragdrop');
|
||||
style('webserver', 'style');
|
||||
|
||||
?>
|
||||
|
||||
<div id="app-content">
|
||||
<h3>Glisser-Déposer pour Ajouter dans Nextcloud</h3>
|
||||
<div id="drop-zone">Déposez vos fichiers ici</div>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user