Jump to content

Does anyone know how to resolve 'C:\fakepath\' when doing an image file upload in a MERN app?


Recommended Posts

I have been trying to find out how to fix an app I had built from a udemy course a while back, I am realizing that gravatar does not work. So I am trying to do a manual file upload for setting a profile pic. I felt discouraged to even ask of this here because there was not a segment on MERN via the course videos. In my actions file i have an auth.js with a register method, I was trying to take the avatar parameter and trying to use the .replace() to strip the C:\fakepath\ prepended string to the filename so that a user image will appear on the client. Has anyone ever encountered this obstacle?

Link to comment
Share on other sites

I just realized now that you cannot upload an image file via application/json. Instead I somehow need to convert my project to use multipart/form-data in a MERN app. But the app uses JWT, so if i use multipart/form-data for registering/logginIn would jwt not work unless i use application/json? But without json how would it be possible to complete this app so that a user auth works so that they are signed into their userProtected Routes so then also user can select their own profile pic so that it shows on profile and user posts? Everything in this app works besides the image upload. Something so mundane but I have to get this to work. Has anyone gone through this before, by any chance?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...