Posts

Showing posts with the label file upload node

Upload Image Using AJAX In Node

Image
Introduction In this blog we see how we can upload image file using ajax.Here we be using FileReader  for reading the selected file and then we send that file data to server side using ajax and on server side we read and save that as image on server. Project Structure Setup Folder Open the command prompt and create new folder using following command mkdir upload Now change   to the newly created folder by using folder command cd upload Setup Node In Folder Now we have to setup node environment in the folder for our project. We have to use the below command to setup node in our folder npm init -y This command will create a package.json file which indicates that node is initialized in folder. The package.json file will look like this Install Packages Now we have to install the package required for building the application. For installing packages we use npm install followed by package name. n

Upload And Download File In Node

Image
Here we will use multer middleware for uploading file . Click the link to know what is  multer . Setup The Project Folder create a new folder using console/terminal. open console/terminal type mkdir followed by the folder name you want to give. change to that folder by typing cd  folder name. Setup Node For The Project now type npm init on console/terminal. the  npm init  will create a  package.json  file.But we can create it manually too. just open the folder and  add a new file  and name it  package.json  and then we can structure it the same way as its been structured when using  npm init . the package.json will look like this. now we will install packages for our project using npm install followed by package names we want to install. the following packages will be installed express ejs body-parser multer mongoose . this will generate a folder name node_modules which will contain all the node packages. after the pac