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

          Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

          Posting a File and Associated Data to a RESTful WebService preferably as JSON2019 Community Moderator ElectionREST URI convention - Singular or plural name of resource while creating itUploading both data and files in one form using Ajax?How do I upload a file with metadata using a REST web service?REST API - file (ie images) processing - best practicesSpring: JSON data and file in the same requestREST API Put large dataPosting a file and JSON data to Spring rest serviceRESTful Web Service Upload/Download Large Data With JSONREST API Design sending JSON data and a file to the api in same requestPost JSONArray to REST servicePUT vs. POST in RESTParsing values from a JSON file?JavaScript/jQuery to download file via POST with JSON dataHow do I upload a file with metadata using a REST web service?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?Separate REST JSON API server and client?what's the correct way to send a file from REST web service to client?How do I write JSON data to a file?What is “406-Not Acceptable Response” in HTTP?REST API - file (ie images) processing - best practices

          How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page