php - jquery.filer remove already uploaded files -


i have problem jquery.filer!

    $(document).ready(function() {         $('#filer_input').filer({           showthumbs: true,           templates: {             box: '<ul class="jfiler-items-list jfiler-items-grid"></ul>',             item: '<li class="jfiler-item">\                         <div class="jfiler-item-container">\                             <div class="jfiler-item-inner">\                                 <div class="jfiler-item-thumb">\                                     <div class="jfiler-item-status"></div>\                                     <div class="jfiler-item-info">\                                         <span class="jfiler-item-title"><b title="{{fi-name}}">{{fi-name | limitto: 25}}</b></span>\                                         <span class="jfiler-item-others">{{fi-size2}}</span>\                                     </div>\                                     {{fi-image}}\                                 </div>\                                 <div class="jfiler-item-assets jfiler-row">\                                     <ul class="list-inline pull-left"></ul>\                                     <ul class="list-inline pull-right">\                                         <li><a class="icon-jfi-trash jfiler-item-trash-action"></a></li>\                                     </ul>\                                 </div>\                             </div>\                         </div>\                     </li>',             itemappend: '<li class="jfiler-item">\                             <div class="jfiler-item-container">\                                 <div class="jfiler-item-inner">\                                     <div class="jfiler-item-thumb">\                                         <div class="jfiler-item-status"></div>\                                         <div class="jfiler-item-info">\                                             <span class="jfiler-item-title"><b title="{{fi-name}}">{{fi-name | limitto: 25}}</b></span>\                                             <span class="jfiler-item-others">{{fi-size2}}</span>\                                         </div>\                                         {{fi-image}}\                                     </div>\                                     <div class="jfiler-item-assets jfiler-row">\                                         <ul class="list-inline pull-left">\                                             <li><span class="jfiler-item-others">{{fi-icon}}</span><span class="jfiler-item-others">{{fi-size2}}</span></li>\                                         </ul>\                                         <ul class="list-inline pull-right">\                                             <li><a class="icon-jfi-trash jfiler-item-trash-action"></a></li>\                                         </ul>\                                     </div>\                                 </div>\                             </div>\                         </li>',             itemappendtoend: false,             removeconfirmation: true,             _selectors: {             list: '.jfiler-items-list',             item: '.jfiler-item',             remove: '.jfiler-item-trash-action'             }             },          addmore: true,          limit:8,          maxsize:2,          extensions: ['jpg','gif','png'],          files: [         <?php          $path=sitebase.'uploads/';          $i = 1;          foreach (unserialize($input['gallery']) $key => $photo) : ?>             {             name: "photo<?=$i?>.jpg",             size: <?=filesize(upload.$photo)?>,             type: "image/jpg",             file: "<?=$path.$photo?>"             },          <?php          $i++;          endforeach; ?>             ]            });                }); 

that's "configuration" of filer.

<form name="photoform" method="post" action="" enctype="multipart/form-data"> <input type="file" name="files[]" id="filer_input" multiple="multiple"> <input type="submit" name="photoformuploadphoto" value="send" /> </form> 

now, in results, displays perfectly. pictures uploaded display on website.

i try upload new files , add database.

$uploader = new uploader();     $data = $uploader->upload($_files['files'], array(         'limit' => 8, //maximum limit of files. {null, number}         'maxsize' => 2, //maximum size of files {null, number(in mb's)}         'extensions' => array('jpg', 'png', 'gif'), //whitelist file extension. {null, array(ex: array('jpg', 'png'))}         'required' => false, //minimum 1 file required upload {boolean}         'uploaddir' => upload, //upload directory {string}         'title' => array('auto', 30), //new file name {null, string, array} *please read documentation in readme.md         'removefiles' => true, //enable file exclusion {boolean(extra jquery.filer), string($_post field name containing json data file names)}         'onremove' => 'onfilesremovecallback' //a callback function name called removing files (must return array) | ($removed_files) | callback     ));      if($data['iscomplete']){         $files = $data['data'];          foreach($files["metas"] $value){            $gallery[]=$value["name"];          imageresize($value["file"], upload.'thumb/'.$value["name"], '190', '114', 0);      }      $sql_update="update `".prefix."users` set `gallery`='".serialize($gallery)."' `id`=".$_post["id"];     query($sql_update);         // echo '<pre>';print_r($files);echo '</pre>';     }      if($data['haserrors']){         $errors = $data['errors'];         //print_r($errors);     }      function onfilesremovecallback($removed_files){         foreach($removed_files $key=>$value){             $file = upload . $value;             $thumb = upload.'thumb/' . $value;              if(file_exists($file)){                 unlink($file);             }             if(file_exists($thumb)){                 unlink($thumb);             }         }          return $removed_files;     } 

unfortunately, $files = $data['data'] return new uploaded files. that's mean uploaded files removed.

do have idea how sort out?

you need to: 1. old files mysql in array 2. add uploaded files old files

$db_images = $db_row['images']; //only example  if($data['iscomplete']){     $files = $data['data'];      foreach($files["files"] $value){         $db_images[] = $value;     } }  // $db_images ready // write query update 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -