1

In an existing site running EE2, with the following working code to upload an image:

ee()->load->library('filemanager');
$uploaded_file = ee()->filemanager->upload_file($directory_id);

The image will appear in the EE File Manager as it should. The problem arises when we want to update this image, replacing the existing file with a new one of the same name. To do this I've tried:

ee()->load->model('file_model');
if (ee()->file_model->get_files_by_name($file_name, $directory_id)->num_rows() > 0) {
    ee()->file_model->delete_files_by_name($dir_id, $file_name);
}

Which in theory would delete the existing image and then let me upload the image again. However it doesn't appear to do anything.

Is there a way in EE2 to upload a replacement image, giving it the same name as the existing image and update the corresponding file manager record?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.