Bläddra i källkod

Fix attachment handling

svalavuo 23 timmar sedan
förälder
incheckning
64821bba30
3 ändrade filer med 3 tillägg och 4 borttagningar
  1. 2 2
      backend/models/Attachment.php
  2. 0 1
      docker-compose.yml
  3. 1 1
      frontend/src/App.vue

+ 2 - 2
backend/models/Attachment.php

@@ -99,7 +99,7 @@ class Attachment {
     }
 
     public function uploadFile($file, $item_id, $file_type) {
-        $uploadDir = '/var/www/html/attachments/';
+        $uploadDir = '/var/www/html/uploads/';
         $allowedTypes = [
             'application/pdf',
             'image/jpeg',
@@ -139,7 +139,7 @@ class Attachment {
             if ($this->create()) {
                 $baseUrl = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]";
                 $apiPath = dirname($_SERVER['PHP_SELF']);
-                $fullUrl = $baseUrl . '/attachments/' . $uniqueFileName;
+                $fullUrl = $baseUrl . '/uploads/' . $uniqueFileName;
                 
                 return ['success' => true, 'url' => $fullUrl, 'id' => $this->conn->lastInsertId()];
             } else {

+ 0 - 1
docker-compose.yml

@@ -27,7 +27,6 @@ services:
       - ALLOWED_FILE_TYPES=${ALLOWED_FILE_TYPES:-pdf,doc,docx,xls,xlsx,jpg,jpeg,png,gif}
     volumes:
       - ./uploads:/var/www/html/uploads
-      - ./attachments:/var/www/html/attachments
     restart: unless-stopped
     healthcheck:
       test: ["CMD", "curl", "-f", "http://localhost/api/company.php"]

+ 1 - 1
frontend/src/App.vue

@@ -510,7 +510,7 @@
                 <span class="attachment-size">({{ formatFileSize(attachment.file_size) }})</span>
               </div>
               <div class="attachment-actions">
-                <a :href="`/attachments/${attachment.file_path}`" target="_blank" class="btn btn-primary">View</a>
+                <a :href="`/uploads/${attachment.file_path}`" target="_blank" class="btn btn-primary">View</a>
                 <button class="btn btn-danger" @click="deleteAttachment(attachment.id)">Delete</button>
               </div>
             </div>