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










0















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.










share|improve this question


























    0















    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.










    share|improve this question
























      0












      0








      0


      1






      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.










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 17:28









      NTN ImperialNTN Imperial

      1216




      1216






















          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
          );



          );













          draft saved

          draft discarded


















          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















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

          2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme