Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.67/5 (3 votes)
Please Helppppppppp Me ,

i have to deliver my task tomorrow morning :( iam new to angularjs , i created a form for sending data to server(webservice) to save it in my database , i saved image like this
JavaScript
$scope.InsertRecord = function () {
        var filedata;
        var f = document.getElementById('file').files[0], r = new FileReader();
        alert(f.length);
        r.onloadend = function (e) {
            filedata = e.target.result;
            //console.log(filedata.length)
            $.ajax({
                type: "POST",
                url: "service.asmx/insertMethod",
                data: "{'title':'" + $scope.news_title + "','desc':'" + $scope.news_content + "' , 'Img':'" + filedata + "'}",
                contentType: "application/json; charset=utf-8",
                //dataType: "application/json",
                success: function (msg) {
                    alert("Inserting Done");
                },
                error: function (xhr,status,error) {
                    alert("ERROR MESSAGE :" + error);
                }
            });

            ResetValues();
        }
        r.readAsDataURL(f);


now iam retrieved it on jason format and it like this [{Image:{Length:2345}}]

i don't know how to convert to image


please help meeee
Posted
Comments
Afzaal Ahmad Zeeshan 19-Dec-15 5:03am    
I would recommend that you get the URL for that image, instead of the image object itself.

Then, use the URL to fetch the image in an image container, such as <img src="jsonResponse.imageUrl" alt="Fetched image" /> In my opinion this is a much suitable method of doing this!

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900