Папка назначения загрузки не может быть доступна для записи. (Codeigniter)

У меня есть два сценария загрузки, которые выполняют очень похожие функции только с разными каталогами.

function town_upload() { //Do not create a thumbnail $create_thumb = false; //Create the path for the upload $path = './public/uploads/towns/' . $this->uri->segment(3); $config['upload_path'] = $path; $config['allowed_types'] = 'jpg'; $config['max_size'] = '2048'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $config['remove_spaces'] = TRUE; $config['overwrite'] = $this->image_upload_overwrite; if ($this->input->post('image_type') == 'main_image') { $config['file_name'] = 'main.jpg'; $create_thumb = true; } $this->load->library('upload', $config); if (!$this->upload->do_upload()) { $this->session->set_flashdata('upload_error', array('error' => $this->upload->display_errors())); } else { //sucess so now we create the thumbnail $this->session->set_flashdata('upload_success', $this->upload->data()); 

Пример. Если бы у меня был город с идентификатором 6, каталог загрузки был бы общедоступным / uploads / towns / 6. Это прекрасно работает, поскольку каталог создается при создании города. У меня почти такая же функция для отелей, за исключением того, что путь открыт для публики / uploads / hotels / [ID]. Я установил разрешения 777, чтобы удалить это из уравнения на данный момент.

Я не могу понять это, так как они оба очень похожи. Вот код загрузки отеля:

  function hotel_upload() { //Create the path for the upload $path = './public/uploads/hotels/' . $this->uri->segment(3); chmod($path, 0777); $config['upload_path'] = $path; $config['allowed_types'] = 'jpg'; $config['max_size'] = '2048'; //kilobytes (2048 = 2mb) $config['max_width'] = '1024'; $config['max_height'] = '768'; $config['remove_spaces'] = TRUE; $config['overwrite'] = TRUE; if ($this->input->post('image_type') == 'main_image') { $config['file_name'] = 'main.jpg'; } $this->load->library('upload', $config); if (!$this->upload->do_upload()) { $this->session->set_flashdata('upload_error', array('error' => $this->upload->display_errors() . ' <br/>Path: ' . $path . '<br/>Image Type: ' . $this->input->post('image_type'))); } else { //sucess so now we create the thumbnail $this->session->set_flashdata('upload_success', $this->upload->data()); 

Функция отеля дает мне ошибку «папка назначения загрузки не может быть доступна для записи».

Вот страницы HTML-форм:

ГОРОД:

 <?php echo form_open_multipart('admin/town_upload/' . $this->uri->segment(3));?> <input type="file" name="userfile" size="20" /> <br /><br /> <p> <input type="radio" name="image_type" checked="checked" class="radio" value="main_image" /> <label>Main Image</label> <input type="radio" name="image_type" class="radio" value="other_image" /> <label>Other Image</label> </p> <input type="submit" class="submit short" value="upload" /> <?php echo form_close(); ?> 

ГОСТИНИЦА:

 <?php echo form_open_multipart('admin/hotel_upload/' . $this->uri->segment(3));?> <input type="file" name="userfile" size="20" /> <br /><br /> <p> <input type="radio" name="image_type" checked="checked" class="radio" value="main_image" /> <label>Main Image (shown when visitors search the website)</label> <input type="radio" name="image_type" class="radio" value="other_image" /> <label>Standard Image</label> </p> <input type="submit" class="submit short" value="upload" /> <?php echo form_close(); ?> 

Заранее спасибо! Работая над этим часами сейчас .. 🙁