Click here to Skip to main content
14,695,609 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am using Ckfinder to manage my photos, I have the following problem as below:

I load up Ckfinder to select an image, then take the image path assigned to the textbox or input tab and at the same time I also want to load the image in the tab

Currently, it got the path assigned to the textbox or but the problem is that in the tab and the image does not load. Please help me on how to do it? thank you very much.
Below is the code which I had written:

$(function () {

           $('#btnUpload').click(function () {
               //e.preventDefault();
               var ckfinder = new CKFinder();
               ckfinder.selectActionFunction = function (fileUrl) {
                   $('#picture').val(fileUrl);
               };
               ckfinder.popup();
           });
           $('#picture').change(function () {

               if (window.FormData != undefined)
               {

                   var fileUpload = $('#picture').get(0);
                   var files = fileUpload.files;
                   var formData = new FormData();
                   formData.append('file', files[0]);
                   $.ajax(
                       {
                           type: 'POST',
                           url: '/Admin/Product/ProcessUpload',
                           contentType: false,
                           processData: false,
                           data: formData,
                           success: function(urlImage)
                           {

                               $('#pictureUpload').attr('src', urlImage);
                               $('#fileUpload').val(urlImage);

                           },
                           error: function (err) {
                               alert('Have the error when upload:' + err.statusText);
                           }
                       });
               }
           });
       });


<div class="form-inline">
                   <input type="text" name="picture" id="picture" class="form-control" style="width:380px;" />
                   <input type="button" id="btnUpload" value="Chọn ảnh" class="btn btn-success"/>
               </div>
               <img id="pictureUpload" width="300" />


What I have tried:

I had tried to fund out the problem but it cannot improve
Posted

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