JS
Node JS
How To Move File In Folder Using Node JS?
Here, i will show you how to works how to move file in node js. Here you will learn node js move file if exists. you'll learn node js move files in folder. i would like to share with you node js move file sync. Follow bellow tutorial step of node js fs move file example.
- TAGS
- Node JS
- 4.5/5.0
- Last updated 08 September, 2022
- By Admin
We will use fs npm package for move file in folder using node.js. fs package provide rename() for move file. let's see simple example
Step 1: Create Node App
run bellow command and create node app.
mkdir my-app cd my-app npm init
Step 2: Create server.js file
Make sure, you have add file on "uploads/laravel-doesnothave-users.png" path.
server.js
const fs = require('fs'); const filePath = './uploads/my-image.png'; const filePathMove = './images/my-image.png'; fs.rename(filePath, filePathMove, function(err) { if ( err ) console.log('ERROR: ' + err); console.log('File Move Successfully.'); });
now you can simply run by following command:
node server.js
Output:
I hope it can help you...
Categories
PHP
(5)
Codeigniter
(5)
Laravel
(3)
JS
(1)
Angular JS
(5)
Node JS
(5)
Vue JS
(4)
React JS
(6)
jQuery
(5)
Javascript
(3)
jQuery UI
(6)
Wordpress
(1)
Python
(5)
Database
(1)
MySql
(5)
Mongo DB
(1)
DBMS
(1)
SQL
(5)
HTML
(1)
HTML 5
(5)
CSS
(5)
Bootstrap
(5)
Ajax
(5)
JAVA
(1)
JSON
(5)
Ubuntu
(5)
Server
(5)
Git
(3)
Google
(1)
Google Map
(7)
Google API
(1)
Elastic Search
(1)
Apache
(1)
Installation
(1)