Welcome Guest, Not a member yet? Register   Sign In
How to delete multiple images
#1

(This post was last modified: 03-27-2022, 10:50 PM by luckmoshy.)

Hi all, May you help me with how to delete multiple images with modal.
I do for one file but I want to assign it like this (array) How?

PHP Code:
public function delete($images_id)       
      {
        
$data $this->model->find($images_id);
        
        
$imagefile1 $data['image1'];
        
$imagefile2 $data['image2'];
        
$imagefile3 $data['image3'];
        
$imagefile4 $data['image4'];
        
        if(
file_exists("imagedirector/"$imagefile)){

             foreach(
$imagefile as $delete){
                
unlink("imagedirector/".$imagefile ++);
             }            
        }
        
$this->model->delete($images_id);        
     } 
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals

Reply
#2

Code:
$media = new UploadModel();
        $file = $media->find($id);
        if (empty($file)) {
            return redirect('uploader');
        }
        $file_path = 'uploads/' . $file['upload_path'] . '/' . $file['file_name'];
        $small_path = 'uploads/' . $file['upload_path'] . '/small/' . $file['file_name'];
        $medium_path = 'uploads/' . $file['upload_path'] . '/medium/' . $file['file_name'];
        $extra_medium_path = 'uploads/' . $file['upload_path'] . '/extramedium/' . $file['file_name'];
        $all_files = array($file_path, $small_path, $medium_path, $extra_medium_path);
        if (!empty($file)) {
            @unlink($file_path);
            @unlink($small_path);
            @unlink($medium_path);
            @unlink($extra_medium_path);
            if ($media->delete($id)) {
                redirect()->to('uploader')->with('message', 'Media and styles are Deleted Successfully From Database');
            } else {
                redirect()->to('uploader')->with('message', 'Media Delete Errors');
            }
        }
        return redirect()->to('uploader');


I am Doing this way
Reply
#3

(03-27-2022, 09:13 PM)rmcdahal Wrote:
Code:
$media = new UploadModel();
        $file = $media->find($id);
        if (empty($file)) {
            return redirect('uploader');
        }
        $file_path = 'uploads/' . $file['upload_path'] . '/' . $file['file_name'];
        $small_path = 'uploads/' . $file['upload_path'] . '/small/' . $file['file_name'];
        $medium_path = 'uploads/' . $file['upload_path'] . '/medium/' . $file['file_name'];
        $extra_medium_path = 'uploads/' . $file['upload_path'] . '/extramedium/' . $file['file_name'];
        $all_files = array($file_path, $small_path, $medium_path, $extra_medium_path);
        if (!empty($file)) {
            @unlink($file_path);
            @unlink($small_path);
            @unlink($medium_path);
            @unlink($extra_medium_path);
            if ($media->delete($id)) {
                redirect()->to('uploader')->with('message', 'Media and styles are Deleted Successfully From Database');
            } else {
                redirect()->to('uploader')->with('message', 'Media Delete Errors');
            }
        }
        return redirect()->to('uploader');


I am Doing this way

cheer worked lol !!!!!!!
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals

Reply
#4

got it now
Reply




Theme © iAndrew 2016 - Forum software by © MyBB