Posts

Showing posts from March, 2020

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

How to Use AJAX with Node

Image
Project Structure                |-------------- models        |                          |-------------- task.js                                    |         |-------------- public        |                          |-------------- data.js        |            |--------------- routes         |                          |-------------- taskroute.js        |         |--------------- views        |                          |-------------- demo.ejs        |         |--------------- app.js Setup The Folder To create a folder, open the command prompt and type cmd mkdir followed by the folder name    # mkdir ajax Change to the folder by typing the cmd cd followed by the folder name  # cd ajax  Setup Node In Folder On the console, type the below command   # npm init -y This will create a package.json file, Which means that node is initialised in the folder. the package.json will look like this  Install Pack

Import CSV File Data Into MongoDB In Node

Image
Setup Folder Open the command prompt and create new folder using the following command followed by folder name. mkdir csv After creating the folder.Change to that folder by using the following command cd csv Setup Node In Folder To setup node in folder use the following command npm init -y This will setup node in our folder.And  after the execution of this command you will see package.json file which means node is initialised. This package.json file will contain the metadata related to our project. The package.json will look like this Install Packages Now we have to install packages to be used to build our application. To install packages we use the following command followed by package name.  npm install csvtojson express ejs mongoose multer body-parser  After installation package.json will look like this Add New Folders Add few new folders in our project folder  models public views Models Folder Add new file