PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, October 20, 2022

[FIXED] How to get all files path from directory in node.js

 October 20, 2022     file, node.js     No comments   

Issue

I'm working on retrieve images from csv file. Right now, i could manage.

  • retrieve data base64 images from a csv file
  • convert base64 image & export it as a .jpeg files in a directory

which the directory is like this

├── assets
    ├── export
        ├── img1.jpeg
        ├── img2.jpeg
        ├── img3.jpeg
        ├── ...

how do i get all imgs path from the export directory?.


Solution

Well looking at the node doc is like this.

const fs = require('fs');

const dirnameExportImg = './assets/export'

fs.readdir(dirnameExportImg, function (err, files) {
  if (err) {
    console.log(err)
  }
  files.map(
    (file) => { console.log(file) }
  )
})


Answered By - Yoarthur
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing