Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Uploading picture using Jquery without submit button and plugin

I want to know how I can upload an image using jquery without submit button just like in facebook you can update your profile picture without a submit button you will select your picture and it will get uploaded

1 Answer

You could set up a "change" event listener on the file input field like so:

$("#fileInput").change(function() {
    $("#uploadFileForm").submit();
});

edit: I tested this in one of my own projects and it works a treat, thanks for the idea!