title: How to Store PDF in mysql database using node js and express
body: <p>I am trying to set up a learning system for a uni project and i need the students to be able to upload a PDF of their work to a Table called Assessment Submissions and I need to store the data in one of the rows... I have looked all over and I know you have to use the blob typing but apart from that I am scuppered (the column in the table is called fileUpload). Any help would be really useful!! I have attached some code that i am working on</p>
  <p><strong>Assessment Models</strong></p>
  <pre><code>exports.submitAssessment = async (pupilID, AssesmentsID, Submission,myfile) =&gt; {
      
  
  
      const assessment = { pupilID, AssesmentsID, Submission, fileUploads:myfile}
      var database = await require('../dbConfig');
       await database.query('INSERT INTO AssessmentSubmissions SET ?', assessment)
  }
  </code></pre>
  <p><em><strong>Assessments Controller</strong></em></p>
  <pre><code>exports.submitAssessment = async (req, res) =&gt; 
  {   
      console.log(req.originalUrl + &quot; POST Received with query: &quot;, session.pupilID, req.params.AssessmentsID, req.body.Submission)
      const submission = await assessments.submitAssessment(session.pupilID, req.params.AssessmentsID, req.body.Submission,req.body.myfile)
      res.send(submission)
  }
  </code></pre>
  <p><strong>Assessment Submission View</strong></p>
  <pre><code>&lt;form class=&quot;&quot; method=&quot;POST&quot; action=&quot;{{{req.params.AssessmentsID}}}/submit-assessment&quot;&gt;
      &lt;label for=&quot;Answer&quot;&gt;Answer&lt;/label&gt;&lt;br&gt;
      &lt;textarea name=&quot;Submission&quot;&gt;&lt;/textarea&gt;
      &lt;label for=&quot;myfile&quot;&gt;Select a file:&lt;/label&gt;
      &lt;input type=&quot;file&quot; id=&quot;myfile&quot; name=&quot;myfile&quot;&gt;&lt;br&gt;&lt;br&gt;
      &lt;input type=&quot;submit&quot; /&gt;
  &lt;/form&gt;
  </code></pre>