Nodejs Course

To easily work with directories and files on server, use the fs-extra module.
It can be a drop in replacement for "fs" build-in module.
- Before using the "fs-extra" module, you have to install it. To install "fs-extra", run this code in command line interface:
npm install --save fs-extra
Then, you can use the fs-extra module in your Node.js projects, as a drop in replacement for native fs.
const fs = require('fs-extra');

Moving directory

A simple way to move a directory in Node.js it is to use the fs.move(oldPath, newPath, callback) method of the fs-extra module.
- Example: move 'dir_2/' directory from 'test/' to 'dirx/':
const fs = require('fs-extra');

fs.move('./test/dir_2/', './dirx/dir_2/', err => {
  if(err) return console.error(err);
  console.log('success!');
});

Copy directory

To copy a directory in Node.js, you can use the copy() method of the fs-extra module.
Example: Copy the 'dir_2/' directory from 'test/' to 'dirx/':
const fs = require('fs-extra');

fs.copy('./test/dir_2/', './dirx/dir_2/', err =>{
  if(err) return console.error(err);
  console.log('success!');
});

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
What attribute makes a radio button or checkbox input selected?
checked="checked" selected="selected" disabled="disabled"
<input type="checkbox" name="a_name" value="value" checked="checked" />
What CSS value scales the background image to the largest size contained within the element?
repeat-x contain linear-gradient
#id {
  background:url("path_to_image.png");
  background-size:contain;
  background-repeat:no-repeat;
}
What operator is used to determine the rest of the division of two numbers?
% * /
var rest8_7 = 8 % 7;
alert(rest8_7);
Indicate the PHP function that rounds a number up to the next highest integer.
floor() ceil() abs()
$nr = ceil(3.5);
echo $nr;        // 4
Node.js Move and Copy Directory

Last accessed pages

  1. Send E-mail with HTML tags and Attachment (5591)
  2. Editing, Changing XML - E4X (1812)
  3. CSS Rhombus Shape (7618)
  4. PHP PDO - prepare and execute (9173)
  5. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (140494)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (69)
  2. Read Excel file data in PHP - PhpExcelReader (11)
  3. ActionScript 3 Lessons (7)
  4. The Mastery of Love (7)
  5. PHP-MySQL free course, online tutorials PHP MySQL code (6)