I'm currently working on a form that includes a custom input group for selecting a local image file. Unfortunately, I am having trouble retrieving the file name in my server code. Despite checking req.body and trying req.file.path, I have been unable to find the property that contains the path location of the image file.
My middleware is bodyParser and I have also experimented with various methods but have not had any success.
<form action="/campgrounds" method="POST" enctype="multipart/form-data">
<div class="form-group">
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text" id="inputGroupFileAddon01">Upload</span>
</div>
<div class="custom-file">
<input type="file" class="custom-file-input" id="inputGroupFile01" aria-describedby="inputGroupFileAddon01" accept="image/*">
<label class="custom-file-label" for="inputGroupFile01">Choose file</label>
</div>
</div>
</div>
</form>
If anyone has insight on how to obtain the file name successfully, please share your knowledge!
Thank you