Skip to content
Snippets Groups Projects
Commit ee892484 authored by Joseph Weston's avatar Joseph Weston
Browse files

allow multiple simultaneous PDF uploads

parent 4b2379bc
No related branches found
No related tags found
No related merge requests found
......@@ -120,21 +120,22 @@ class Exams extends React.Component {
alert('Please upload a PDF..')
return
}
var data = new FormData()
data.append('pdf', accepted[0])
api.post('pdfs/' + this.state.selected_exam.id, data)
.then(() => {
api.get('pdfs/' + this.state.selected_exam.id)
.then(pdfs =>
this.setState(prev => ({
selected_exam: Object.assign(prev.selected_exam, {pdfs: pdfs})
}))
)
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)
accepted.map(file => {
var data = new FormData()
data.append('pdf', file)
api.post('pdfs/' + this.state.selected_exam.id, data)
.then(() => {
api.get('pdfs/' + this.state.selected_exam.id)
.then(pdfs =>
this.setState(prev => ({
selected_exam: Object.assign(prev.selected_exam, {pdfs: pdfs})
}))
)
})
.catch(resp => {
alert('failed to upload pdf (see javascript console for details)')
console.error('failed to upload PDF:', resp)
})
})
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment