How change image name before save in folder


#1

i am saving a image but i want rename her before save. How i can do it?


#2

when using ‘move’ function on file, give it name like this:

await profilePic.move(Helpers.tmpPath('uploads'), {name: 'my-photo.jpg'})

For example, if we make form with action \upload’ (dont forget about csrf field! see doc), all we need to add in controller:

async upload ({request, response}) {
const uplFile = request.file('uploaded')
		await uplFile.move('public/upload', {name: 'newfile.jpg'})
		if (!uplFile.moved()) {
			return uplFile.error()
		}
		return "File moved"
	}

File will be moved in ‘upload’ folder in our ‘public’