08-24-2017, 01:22 AM (This post was last modified: 08-24-2017, 01:29 AM by JanFromHamburg.)
How many images do you try to resize in one step by that function?
Is there any pattern? Does it stop after a particular quantity or image size or filetype? Did you try on different batches of images?
Do the images have similar names or get names cut off and files do get overwritten
Any logfile information from the server?
I did not try out your code. But you could count or check images in the beginning, write a logfile line for each resizing and publish these information at the end or by ajax
And also use use a if file exists for resize check and also codeigniter img() helper function helped also. I also did the $config for the resize in an array $config[] = array();
if (!$this->image_lib->resize()) { return $this->image_lib->display_errors(); } else { return base_url('image/cache/') . $new_image; } } /** * Codeigniter upload library with json and config_item */ public function upload() { $json = array(); $input_get_directory = $this->input->get('directory'); if (isset($input_get_directory)) { $directory = 'image/catalog/' . $input_get_directory; } else { $directory = 'image/catalog'; } $config['upload_path'] = './' . $directory . '/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = 5000; $config['max_width'] = '0'; $config['max_height'] = '0'; $config['overwrite'] = FALSE; $this->load->library('upload', $config); $this->upload->initialize($config); $input_name = "file"; if ($this->upload->do_upload($input_name) == FALSE) { $json['error'] = $this->upload->display_errors(); } else { $file_data = $this->upload->data(); $json['success'] = "This file" . ' ' . $file_data['file_name'] . ' ' . "has been uploaded"; } $this->output->set_content_type('Content-Type: application/json'); $this->output->set_output(json_encode($json)); } public function folder() { $json = array(); $input_get_directory = $this->input->get('directory'); // Make sure we have the correct directory if (isset($input_get_directory)) { $directory = FCPATH . 'image/catalog/' . $input_get_directory; } else { // Do not add extra tralier slash at end / $directory = FCPATH . 'image/catalog'; } // Check its a directory if (!is_dir($directory)) { $json['error'] = $this->lang->line('error_directory'); } if (!$json) { $input_get_folder = $this->input->post('folder'); // Sanitize the folder name $folder = str_replace(array('../', '..\\', '..'), '', basename(html_entity_decode($input_get_folder, ENT_QUOTES, 'UTF-8'))); // Validate the filename length if ((utf8_strlen($folder) < 3) || (utf8_strlen($folder) > 128)) { $json['error'] = $this->lang->line('error_folder'); } // Check if directory already exists or not if (is_dir($directory . '/' . $folder)) { $json['error'] = $this->lang->line('error_exists'); } } if (!$json) { mkdir($directory . '/' . $folder, 0777); $json['success'] = $this->lang->line('text_directory'); }
$this->output->set_content_type('Content-Type: application/json'); $this->output->set_output(json_encode($json)); } public function delete() { $json = array(); $input_path_post = $this->input->post('path'); if (isset($input_path_post)) { $paths = $input_path_post; } else { $paths = array(); } // Loop through each path to run validations foreach ($paths as $path) { $path = rtrim(FCPATH . 'image/' . str_replace(array('../', '..\\', '..'), '', $path), '/'); // Check path exsists if ($path == FCPATH . 'image/' . 'catalog') { $json['error'] = $this->lang->line('error_delete'); break; } } if (!$json) { // Loop through each path foreach ($paths as $path) { $path = rtrim(FCPATH . 'image/' . str_replace(array('../', '..\\', '..'), '', $path), '/'); // If path is just a file delete it if (is_file($path)) { unlink($path); // If path is a directory beging deleting each file and sub folder } elseif (is_dir($path)) { $files = array(); // Make path into an array $path = array($path . '*'); // While the path array is still populated keep looping through while (count($path) != 0) { $next = array_shift($path); foreach (glob($next) as $file) { // If directory add to path array if (is_dir($file)) { $path[] = $file . '/*'; } // Add the file to the files to be deleted array $files[] = $file; } } // Reverse sort the file array rsort($files); foreach ($files as $file) { // If file just delete if (is_file($file)) { unlink($file); // If directory use the remove directory function } elseif (is_dir($file)) { rmdir($file); } } } } $json['success'] = $this->lang->line('text_delete'); } $this->output->set_content_type('Content-Type: application/json'); $this->output->set_output(json_encode($json)); } }
There's only one rule - please don't tell anyone to go and read the manual. Sometimes the manual just SUCKS!