Coder Social home page Coder Social logo

avatarupload's Introduction

Avatar Upload in MVC 5

ASP.NET MVC 5 avatar upload implementation

This project is based on ASP.NET MVC 5 and can be used as an example of how to implement user avatar uploading and cropping. It uses jquery, jquery.form, and jcrop and it has some extra code to manipulate the image before saving it locally.

The project contains an AvatarController.cs controller class that contains the back-end code for receiving the uploaded file and saving the final, cropped selection.

The Views/Avatar folder contains the main partial view that has three distinct parts - a box for selecting a file and showing the upload progress, a box for cropping the image, and a box for displaying the result of the manipulation. All operations are done on one page (view) for a smooth, contained solution.

Run the example

To try the functionality, just run the project, click on the Avatar Upload item in the navigation bar (top menu), and use the buttons on the page to upload and crop an image.

The steps you should follow on the /Avatar/Upload page so you can see the example in action are:

  1. Click "Browse" (or "Choose File" or whatever your browser flavour provides you with) and select an image file.
  2. Click "Open" - a resized file is stored in a /Temp folder on the server (or locally).
  3. Select a part of the image (on the left) to crop (in this example cropping is done according to a 1:1 aspect ratio, i.e. the avatar is square). The cropped result (what the final avatar will look like) is displayed and updated on the right side of the page as the selection changes.
  4. Click the "Save Avatar" button - the cropped file is saved in the /Avatars folder on the server (locally).

Feel free to clone and modify the project for your needs. Look at all the ToDo's in it so you can customize the basic behaviour. The rest is up to you.

Good luck!

avatarupload's People

Contributors

codative avatar miroj avatar williamhallatt avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.