How to get folder relative path on client machine using multer NodeJS?2019 Community Moderator ElectionHow do I get started with Node.jsHow do I get the path to the current script with Node.js?How can I update NodeJS and NPM to the next versions?How to get GET (query string) variables in Express.js on Node.js?How to make node.js require absolute? (instead of relative)Decide the upload folder location of Multer middlewareuploading file using multer is not working fully (nodejs)How to send an array of files to express backendupload and post a file from client (react js) to nodejs express serverFile cannot be saved using multer
Does the attack bonus from a Masterwork weapon stack with the attack bonus from Masterwork ammunition?
World War I as a war of liberals against authoritarians?
Is it insecure to send a password in a `curl` command?
Generic TVP tradeoffs?
Print last inputted byte
Should I use acronyms in dialogues before telling the readers what it stands for in fiction?
Loading the leaflet Map in Lightning Web Component
How is the partial sum of a geometric sequence calculated?
Maths symbols and unicode-math input inside siunitx commands
Are dual Irish/British citizens bound by the 90/180 day rule when travelling in the EU after Brexit?
What is the relationship between relativity and the Doppler effect?
Describing a chess game in a novel
Should I be concerned about student access to a test bank?
What is the significance behind "40 days" that often appears in the Bible?
HP P840 HDD RAID 5 many strange drive failures
Recruiter wants very extensive technical details about all of my previous work
How to get the n-th line after a grepped one?
Am I eligible for the Eurail Youth pass? I am 27.5 years old
Synchronized implementation of a bank account in Java
Bash - pair each line of file
Why is there so much iron?
Deletion of copy-ctor & copy-assignment - public, private or protected?
Probably overheated black color SMD pads
Can a wizard cast a spell during their first turn of combat if they initiated combat by releasing a readied spell?
How to get folder relative path on client machine using multer NodeJS?
2019 Community Moderator ElectionHow do I get started with Node.jsHow do I get the path to the current script with Node.js?How can I update NodeJS and NPM to the next versions?How to get GET (query string) variables in Express.js on Node.js?How to make node.js require absolute? (instead of relative)Decide the upload folder location of Multer middlewareuploading file using multer is not working fully (nodejs)How to send an array of files to express backendupload and post a file from client (react js) to nodejs express serverFile cannot be saved using multer
I am attempting to let the client be able to upload folder to the server using React as front-end and NodeJS as back-end.
When onChange
event of <input type="file" ... />
triggered, I log the property target.files
of the event to the console, the result is:
0: File
lastModified: 1551972912122
lastModifiedDate: Thu Mar 07 2019 22:35:12 GMT+0700 (Indochina Time)
name: "1"
size: 0
type: ""
webkitRelativePath: "a/1"
__proto__: File,
1: File
lastModified: 1551976477060
lastModifiedDate: Thu Mar 07 2019 23:34:37 GMT+0700 (Indochina Time)
name: "2"
size: 1010
type: ""
webkitRelativePath: "a/c/2"
__proto__: File
I want to recreate those files in my server side, that is: the root folder is a
, a
has two chilren folder: c
and file 1
, folder c
has one child: file 2
.
When using multer
, however, I have no information of relative path of the file at the client side (that's is no information about its parent at the client side), which is difficult for me to restructure the folder. The only thing I know is the relative path at which it is saved on the server side, I choose public/uploads
because I dont know it relative path on the client side:
fieldname: 'plaintext',
originalname: '1',
encoding: '7bit',
mimetype: 'application/octet-stream',
destination: 'public/uploads/',
filename: '1',
path: 'public/uploads/1',
size: 0
So, how can I tackle this? Thanks in advance.
node.js reactjs multer
add a comment |
I am attempting to let the client be able to upload folder to the server using React as front-end and NodeJS as back-end.
When onChange
event of <input type="file" ... />
triggered, I log the property target.files
of the event to the console, the result is:
0: File
lastModified: 1551972912122
lastModifiedDate: Thu Mar 07 2019 22:35:12 GMT+0700 (Indochina Time)
name: "1"
size: 0
type: ""
webkitRelativePath: "a/1"
__proto__: File,
1: File
lastModified: 1551976477060
lastModifiedDate: Thu Mar 07 2019 23:34:37 GMT+0700 (Indochina Time)
name: "2"
size: 1010
type: ""
webkitRelativePath: "a/c/2"
__proto__: File
I want to recreate those files in my server side, that is: the root folder is a
, a
has two chilren folder: c
and file 1
, folder c
has one child: file 2
.
When using multer
, however, I have no information of relative path of the file at the client side (that's is no information about its parent at the client side), which is difficult for me to restructure the folder. The only thing I know is the relative path at which it is saved on the server side, I choose public/uploads
because I dont know it relative path on the client side:
fieldname: 'plaintext',
originalname: '1',
encoding: '7bit',
mimetype: 'application/octet-stream',
destination: 'public/uploads/',
filename: '1',
path: 'public/uploads/1',
size: 0
So, how can I tackle this? Thanks in advance.
node.js reactjs multer
add a comment |
I am attempting to let the client be able to upload folder to the server using React as front-end and NodeJS as back-end.
When onChange
event of <input type="file" ... />
triggered, I log the property target.files
of the event to the console, the result is:
0: File
lastModified: 1551972912122
lastModifiedDate: Thu Mar 07 2019 22:35:12 GMT+0700 (Indochina Time)
name: "1"
size: 0
type: ""
webkitRelativePath: "a/1"
__proto__: File,
1: File
lastModified: 1551976477060
lastModifiedDate: Thu Mar 07 2019 23:34:37 GMT+0700 (Indochina Time)
name: "2"
size: 1010
type: ""
webkitRelativePath: "a/c/2"
__proto__: File
I want to recreate those files in my server side, that is: the root folder is a
, a
has two chilren folder: c
and file 1
, folder c
has one child: file 2
.
When using multer
, however, I have no information of relative path of the file at the client side (that's is no information about its parent at the client side), which is difficult for me to restructure the folder. The only thing I know is the relative path at which it is saved on the server side, I choose public/uploads
because I dont know it relative path on the client side:
fieldname: 'plaintext',
originalname: '1',
encoding: '7bit',
mimetype: 'application/octet-stream',
destination: 'public/uploads/',
filename: '1',
path: 'public/uploads/1',
size: 0
So, how can I tackle this? Thanks in advance.
node.js reactjs multer
I am attempting to let the client be able to upload folder to the server using React as front-end and NodeJS as back-end.
When onChange
event of <input type="file" ... />
triggered, I log the property target.files
of the event to the console, the result is:
0: File
lastModified: 1551972912122
lastModifiedDate: Thu Mar 07 2019 22:35:12 GMT+0700 (Indochina Time)
name: "1"
size: 0
type: ""
webkitRelativePath: "a/1"
__proto__: File,
1: File
lastModified: 1551976477060
lastModifiedDate: Thu Mar 07 2019 23:34:37 GMT+0700 (Indochina Time)
name: "2"
size: 1010
type: ""
webkitRelativePath: "a/c/2"
__proto__: File
I want to recreate those files in my server side, that is: the root folder is a
, a
has two chilren folder: c
and file 1
, folder c
has one child: file 2
.
When using multer
, however, I have no information of relative path of the file at the client side (that's is no information about its parent at the client side), which is difficult for me to restructure the folder. The only thing I know is the relative path at which it is saved on the server side, I choose public/uploads
because I dont know it relative path on the client side:
fieldname: 'plaintext',
originalname: '1',
encoding: '7bit',
mimetype: 'application/octet-stream',
destination: 'public/uploads/',
filename: '1',
path: 'public/uploads/1',
size: 0
So, how can I tackle this? Thanks in advance.
node.js reactjs multer
node.js reactjs multer
asked Mar 7 at 17:28
NTN ImperialNTN Imperial
1216
1216
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55049709%2fhow-to-get-folder-relative-path-on-client-machine-using-multer-nodejs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55049709%2fhow-to-get-folder-relative-path-on-client-machine-using-multer-nodejs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown