uploading a file with a post and display results

Skip to first unread message

Gregg Fiehler

Aug 24, 2016, 10:37:39 PM8/24/16
to Sammy.js
I am sure this is a newbie question as I have little javascript and sammy.js experience, but I am submitting a form to a sammy route, my text input and hidden input shows up as this.params, but my file input does not.  How do I access input from a

<form action="#/my/route" method="post" enctype="multipart/form-data">
  <input type="file" name="file" id="file" \> 
  <input type="submit" value="Upload Subscriptions" />

 sammy.post('#/my/route', function() {
    req.open('POST', '/api/file', false);
    req.setRequestHeader('content-type', 'multipart/form-data');

but the api does not seem to get the file.  

if I use

<input type="submit" value="Upload subscription definitions"  onclick="submit_import(submit_subscriptions_import($(this).closest('form')[0]))" />

and then 

function submit_subscriptions_import(form) { 
   form.method = "post";  
   form.action = "api/file";

then the api gets the file, however, it then displays the response which is a json file of information as raw json, I need to capture this response and display it in a table.  
 was hoping I could submit to a route as I do with other posts with no issues, but I cannot figure out how to manage the file in that case.

Any help would be appreciated


Reply all
Reply to author
0 new messages