Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

express download file

app.get((req, res, next) => {
  res.download('/file/to/be/downloaded.ext');
  res.status(200);
});
Comment

Download A File With Link Using ExpressJS

/*index.ejs*/
<body>
	<a href='download/'><img src='/images/downloadbutton.png'/></a>
</body>

/*indexController.js*/
exports.download = async function(req, res, next)
{ 
 
res.download("public/downloads/text.txt";
}
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: get pods running on a node 
Javascript :: js import jquery 
Javascript :: how create a delay for html js 
Javascript :: angular call function on option select 
Javascript :: Convert a string to a number in jQuery 
Javascript :: js get element type 
Javascript :: loop array and check if value matches in js 
Javascript :: reload table jquery 
Javascript :: clear arrays in jquery 
Javascript :: how to get http request and store the response in a variable in angular 
Javascript :: add variables in javascript 
Javascript :: prime or not in javascript 
Javascript :: expo image picker 
Javascript :: bootstrap modal disable close on click outside react bootstrap 
Javascript :: javascript remove all style values in div 
Javascript :: javascript check if number is integer 
Javascript :: utc to local time javascript 
Javascript :: new nextjs project 
Javascript :: Parcel, how to fix the `regeneratorRuntime is not defined` error 
Javascript :: check if string is datestring javascript 
Javascript :: ajax get form data 
Javascript :: append to top javascript 
Javascript :: javascript on image load 
Javascript :: get monitor width javascript 
Javascript :: remove appended element jquery 
Javascript :: move file from one folder to another in aws s3 nodejs 
Javascript :: remove axis tick ends d3 
Javascript :: factorial of number js 
Javascript :: javascript redirect to route laravel 
Javascript :: store id of an element jquery 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =