<?php
namespace App\Controllers;

use App\Core\Controller;
use App\Core\Database;

class AuthorController extends Controller
{
    public function uploadRevision()
    {
        $db = Database::getInstance();
        $id = $_POST['submission_id'];

        $uploadDir = BASE_PATH.'/storage/submissions/';
        $fileName = time().'_revision_'.basename($_FILES['file']['name']);
        move_uploaded_file($_FILES['file']['tmp_name'],$uploadDir.$fileName);

        $db->prepare("UPDATE submissions SET revision_file=? WHERE id=?")
           ->execute([$fileName,$id]);

        header("Location: /easychair/author/dashboard");
        exit;
    }
}
