From 8bdecde058e987d55fb6154bb0625c0949498001 Mon Sep 17 00:00:00 2001 From: Joseph Weston <joseph.weston08@gmail.com> Date: Mon, 5 Feb 2018 15:15:25 +0100 Subject: [PATCH] copy and paste logic to upload PDFs The backend still does nothing --- client/views/Exams.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/client/views/Exams.js b/client/views/Exams.js index 76cf80bef..f27747153 100644 --- a/client/views/Exams.js +++ b/client/views/Exams.js @@ -92,10 +92,18 @@ class Exams extends React.Component { onDropPDF(accepted, rejected) { if (rejected.length > 0) { alert('Please upload a PDF..') - } else { - // TODO: implement PDF upload - console.log('would upload PDF here') + return } + var data = new FormData() + data.append('pdf', accepted[0]) + api.post('pdfs/' + this.state.selected_exam.id, data) + .then(() => { + alert('Thank you for your upload, it was delicious') + }) + .catch(resp => { + alert('failed to upload pdf (see javascript console for details)') + console.error('failed to upload PDF:', resp) + }) } componentDidMount() { -- GitLab