path module က file path တွေကို operating system မတူလည်းမှန်ကန်အောင်တည်ဆောက်ပေးတဲ့ built-in utility ပါ။ Windows မှာ \, macOS/Linux မှာ / သုံးတာမတူတဲ့အတွက် string ကိုလက်နဲ့ဆက်ရေးတာထက် path.join() သုံးတာပိုလုံခြုံပါတယ်။
const path = require('path');
const filePath = path.join(__dirname, 'uploads', 'profile.png');
console.log('Full Path:', filePath);
console.log('File Name:', path.basename(filePath));
console.log('Folder:', path.dirname(filePath));
console.log('Extension:', path.extname(filePath));__dirname က လက်ရှိ file ရှိနေတဲ့ folder path ကိုပြန်ပေးပါတယ်။ path.join() က path segment တွေကို OS နဲ့ကိုက်ညီအောင်ဆက်ပေးပါတယ်။ basename, dirname, extname တွေက file info တွေခွဲထုတ်ပေးပါတယ်။
Full Path: /your-project/uploads/profile.png File Name: profile.png Folder: /your-project/uploads Extension: .pngInfo
Upload file, image path, template path, static file path တွေမှာ path.join() ကိုသုံးရင် cross-platform issue လျော့သွားပါတယ်။