2010-05-12 10 views
0

많은 수정 제안이 있지만 그 중 어떤 것도 저에게 적합하지 않습니다. 다음 메소드를 사용하여 업로드 클래스를 만들려고했습니다 : Method1Method2). 내가 업로드를 시도하는 파일 형식은Codeigniter를 사용하여 mp3 파일을 업로드 할 수 없습니다

다음

내 모델에 대한 내 코드는 나의 양식을 사용할 수 없습니다

다음과 같은 오류 메시지를받을 mp3 파일을 (내가했습니다 업로드 할 때 매우 마른 체형의 컨트롤러를 가졌다). 누군가가 이것으로 나를 도울 수 있다면 나는 영원히 감사 할 것입니다.

모델

function do_upload() 
{ 

     $soundfig['upload_path'] = './uploads/nav'; 
     $soundfig['allowed_types'] = 'mp3'; 

     $this->load->library('upload', $soundfig); 

     if (! $this->upload->do_upload()) 
     { 
      $error = array('error' => $this->upload->display_errors()); 

      return $error; 
     } 
     else 
     { 

      /* $data = $this->upload->data('userfile'); */ 
      $sound = $this->upload->data(); 
      /* $full_path = 'uploads/nav/' . $data['file_name']; */ 
      $sound_path = 'uploads/nav/' . $sound['file_name']; 

      if($this->input->post('active') == '1'){ 
       $active = '1'; 
      }else{ 
       $active = '0'; 
      } 

      $spam = array(
       /* 'image_url' => $full_path, */ 
       'sound' => $sound_path, 
       'active' => $active, 
       'url' => $this->input->post('url') 
      ); 

      $id = $this->input->post('id'); 

      $this->db->where('id', $id); 
      $this->db->update('NavItemData', $spam); 

      return true; 

    } 
} 

보기 양식 내가이 업로드 문서에 비슷한 문제가 있었다 네

<?php echo form_open_multipart('upload/do_upload');?> 
<?php if(isset($buttons)) : foreach($buttons as $row) : ?> 
<h2><?php echo $row->name; ?></h2> 
<!-- <input type="file" name="userfile" size="20" /><br /> --> 
<input type="file" name="userfile" size="20" /> 
<input type="hidden" name="oldfile" value="<?php echo $row->image_url; ?>" /> 
<input type="hidden" name="id" value="<?php echo $row->id; ?>" /> 

<br /><br /> 
<label>Url: </label><input type="text" name="url" value="<?php echo $row->url; ?>" /><br /> 
<input type="checkbox" name="active" value="1" <?php if($row->active == '1') { echo 'checked'; } ?> /><br /><br /> 
<input type="submit" value="submit" /> 

</form> 

<?php endforeach; ?> 
<?php endif; ?> 

답변

4

/CodeIgniter의의 파일 업로드 클래스와 이미지 유형; 내가 네 응용 프로그램에서

/설정/mimes.php

'jpeg' => array('image/jpeg', 'image/pjpeg', 'application/octet-stream'), 
'jpg' => array('image/jpeg', 'image/pjpeg', 'application/octet-stream'), 
'jpe' => array('image/jpeg', 'image/pjpeg', 'application/octet-stream'), 
'png' => array('image/png', 'image/x-png', 'application/octet-stream'), 
+0

: 내 주위의 작업은 내가 너무 등으로 문제가 된 각 유형에 대한 '응용 프로그램/octet-stream을'마임 유형을 추가하는 것이 었습니다 그것도 발견했다. mime 클래스에 추가 mimes를 추가해야했습니다. – Drew

관련 문제