Skip to content

Upload image by converting to base64 string and then displaying it back to user using Node,Express,Mongo,Jade.

Notifications You must be signed in to change notification settings

deepikagunda/imageUpload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Configuration

  • Platform: node

  • Framework: express

  • Template Engine: jade

  • CSS Framework: bootstrap

  • CSS Preprocessor: css

  • JavaScript Framework:

  • Build Tool: none

  • Unit Testing: none

  • Database: mongodb

  • Deployment: none

  • How to run this project :

  • 1.Setup mongoose or use mlab to save the user to database.

  • 2.download this project.

  • 3.open server.js and add the mongo connection details and the collection name .I have used "Demo" as collection name.

  • 4.Update and install node packages .use npm install

  • 5.Launch the project http://localhost:3000.

  • 6.Give a name , email and choose a photograph to upload.Press the upload button.

  • When the image file is uploaded ,i resize the file to 200 * 200 px on the client side and then use ajax to upload this file to uploads/pics/xxxxx.extn .This same path is stored in a hidden form element.

  • When the updateProfile button is clicked then a new user is created in collection and the path to the photograph /uploads/pics is stored in the mongodb.

  • Once new user is created ,the image is read from the path in the mongo, it is in binary format.It is converted to base64 string and sent to the front end.The image is now displayed as a 120 *120 px photo.

  • A lot of error handling is to be done ,if using this code in production.

  • From this project ..you will know how to read a photo file .Resize it in client side.

  • Send it using ajax. Then rebuilding the image file from binary to base64 and back to a png/jpeg to be displayed using express and jade.

Good luck!

About

Upload image by converting to base64 string and then displaying it back to user using Node,Express,Mongo,Jade.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published