mirror of
https://gitlab.com/animath/si/plateforme-corres2math.git
synced 2025-06-25 19:37:23 +02:00
Phase 2 : pièces jointes dans les questions
This commit is contained in:
@ -25,10 +25,38 @@ if ($file !== null) {
|
||||
$surname = $user->getSurname();
|
||||
$first_name = $user->getFirstName();
|
||||
$name = "Autorisation de droit à l'image de $first_name $surname.pdf";
|
||||
} else
|
||||
require_once "server_files/404.php";
|
||||
|
||||
header("Content-Type: application/pdf");
|
||||
header("Content-Type: application/pdf");
|
||||
}
|
||||
else {
|
||||
$question = Question::fromAttachedFile($id);
|
||||
if ($question != null)
|
||||
{
|
||||
$from = Team::fromId($question->getFrom());
|
||||
$to = Team::fromId($question->getTo());
|
||||
$mime_type = finfo_file(finfo_open(FILEINFO_MIME_TYPE), "$LOCAL_PATH/files/$id");
|
||||
$name = "Pièce jointe de l'équipe " . $from->getTrigram() . " pour l'équipe " . $from->getTrigram();
|
||||
switch ($mime_type) {
|
||||
case "application/pdf":
|
||||
$name .= "pdf";
|
||||
break;
|
||||
case "image/png":
|
||||
$name .= ".png";
|
||||
break;
|
||||
case "image/jpg":
|
||||
case "image/jpeg":
|
||||
$name .= ".jpg";
|
||||
break;
|
||||
case "application/zip":
|
||||
$name .= ".zip";
|
||||
break;
|
||||
}
|
||||
header("Content-Type: " . $mime_type);
|
||||
}
|
||||
else
|
||||
require_once "server_files/404.php";
|
||||
}
|
||||
|
||||
header("Content-Disposition: inline; filename=\"$name\"");
|
||||
|
||||
readfile("$LOCAL_PATH/files/$id");
|
||||
|
Reference in New Issue
Block a user