Click here to Skip to main content
11,929,249 members (48,604 online)
Rate this:
Please Sign up or sign in to vote.
See more: Ajax
Is it possible to preview the excel file content without uploading but after selected

using ajax.....
Posted 5-Dec-12 2:35am
aspnet_regiis -i 5-Dec-12 9:11am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Yes you can. You can use JSON and Web Service.

<input type="file" id="files" name="files[]" multiple />

 <script type="text/javascript">
 document.getElementById('files').addEventListener('change', handleFileSelect, false);
function handleFileSelect(evt) {
                var fileUpload = document.getElementById('files');
                var files =; // FileList object
                // Loop through the FileList and render image files as thumbnails.
                for (var i = 0, f; f = files[i]; i++) {
                    var reader = new FileReader();
                    var base64Data;
                        reader.onload = (function (theFile) {
                            return function (e) {
                                base64Data =;
                        // Read in the image file as a data URL.

 function StoreDocument(base64Data) {
                    type: "POST",
                    url: "DocumentUpload.asmx/Base64ToFile",
                    data: "{ 'base64': '" + base64Data + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (response) {
                        base64Data = response.d;
                    failure: function (msg) {

Now Create WebService for DocumentUpload.asmx and Make a method Base64ToFile(string base64)
now you can convert the base64 string to byte or you can save to database.

Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151126.1 | Last Updated 5 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100