Note that there are some explanatory texts on larger screens.

plurals
  1. POReading blob data using PHP and JavaScript
    primarykey
    data
    text
    <p>I have an application where a user is allowed to save some text data into a MYSQL database through a web interface. In addition, they can also attach a file to this text and I save this into a blob field. The file types that get attached are simple .txt files.</p> <p>I am able to save this data into the database but I am having trouble retrieving it. This is what I am doing to retrieve it right now:</p> <pre><code>//Events that take place when trying to retreive an attached file function getFile(rowid){ //Make an AJAX Request to fetch the file $.ajax({ type: 'get', url: 'point-of-contact.php', data: 'page=attachment&amp;row='+rowid, dataType: 'text', success: function(data) { console.log (data); } }); } </code></pre> <p>The AJAX request above leads to the following PHP code:</p> <pre><code>$attachments = $poc -&gt; getPOC($_GET['row']); header('Content-type: text/plain'); echo $attachments; </code></pre> <p>The problem I face is that when I console log the data received from the AJAX request I get this:</p> <p><img src="https://i.stack.imgur.com/AEr8H.png" alt="enter image description here"></p> <p>How do I go about getting the data in simple text format?</p> <p>Could it be that the way I am uploading the file to the database is incorrect? This is how the file is uploaded to the DB:</p> <pre><code> //File upload code var fileInput = document.getElementById('upload'); var file = fileInput.files[0]; //Hide the save button $("#save-button-1").hide(); //Make the AJAX request $.ajax({ type: 'post', url: 'point-of-contact.php?page=add', data: 'point_of_contact=' + $("#textarea1").val() + '&amp;point_of_contact_attachment=' + file, success: function(data) { $('#done-1').show(); setTimeout(function() { $('#done-1').fadeOut(); }, 2500); $('.loader').fadeOut(); } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload