Storing or retrieving data from database via ajax is more common and easier than uploading an image to server using ajax.Since ajax works without page refresh so uploading images too via ajax is a great technique to totally ajaxify your website and let the user have a smooth experience while scrolling various sections/pages of your website.
Below is the ajax script to upload file to server and perform get saved location file name as a response.
Use this link to download additional files: [highlight] Files.rar[/highlight]
File upload is triggered by the click of a submit button as shown below:
<script src="http://code.jquery.com/jquery-latest.js"></script> <input type="file" name="fileToUpload" id="fileToUpload" /> <input type="button" value="Save" onclick="savepic()" /> //you can also use event listeners instead of onclick here