Sunday, 16 April 2017

get file path using fetch API on cilent side?

I used aws-sdk in node.js,

s3BucketMgt=require("s3-nodejs-sample");
var config=require("./config.js");
var bucketName="node-sdk-sample-cbt-003";
var fileToUpload = "D:/gitHub/awt-nodejs-sample/s3-nodejs-sample/logo.jpg";
s3BucketMgt.uploadFile(bucketName,fileToUpload,"null",config,function(data){
 if(data.status==false){
  console.log("Error in Upload file:"+data.error);
 }else{
  console.log("File Uploaded in Bucket.");
 }
});

it required a file path from the cilent side. I'm using fetch, how can I get the file's path using <input type="file"/>?

I've tried

const input = document.querySelector('input[type="file"]');
const data = new FormData();
data.append('file', input.files[0]);
console.log(data)

but there's no file path.



via Jenny Mok

No comments:

Post a Comment