일부 이미지 업로드에 문제가 있습니다. 그래서 ... 관리자 쪽에서 "이미지 추가"버튼을 클릭하고 이미지 추가를 시작합니다. 이미지를 추가하기 시작할 때 볼 수 있도록 이미지가 표시되지 않습니다. 저장을 클릭하면 이미지가 특정 위치에 저장됩니다. 제 질문은 : 이미지 추가 버튼을 클릭 한 후에 왜 내 이미지를 볼 수 없습니까? 사진이 내가 지정한 경로에 저장되지 않는 이유는 무엇입니까? 감사합니다. 또한 여기에 몇 가지 코드를 추가 :
이 내 컨트롤러에 있습니다
아약스를 사용하여 codeigniter의 이미지 업로드
public function showcase_image(){
try{
$config['upload_path'] = './resources/media/showcase/image/';
$config['allowed_types'] = 'jpeg|png|jpg|flv|mp3|wav';
$config['max_size'] = '10000';
$this->load->library('upload', $config);
$this->upload->do_upload('add_image');
$data = $this->upload->data();
$w = 720;
$h = 425;
$this->load->library('image_lib');
$config['image_library'] = 'gd2';
$config['source_image'] = $data['full_path'];
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['thumb_marker'] = '';
$config['width'] = $w;
$config['height'] = $h;
$this->image_lib->initialize($config);
if($data['image_width']<425 && $data['image_height']<425){
}else{
$this->image_lib->resize();
}
$file = $data['file_name'];
echo json_encode(array("error"=>false,"msg"=>"success","file"=>$file,"dir"=>"image"));
}catch(Exception $e) {
echo json_encode(array("error"=>true,"msg"=>$e->getMessage()));
}
}
이 내 모델에 있습니다
public function getShowcases(){ $query = $this->db->query("SELECT * FROM showcase ORDER BY showcase_id DESC"); $result = $query->result(); return $result; } public function getImagesShowcase($idShowcase){ $query = $this->db->query("SELECT * FROM showcase_gallery WHERE showcase_gallery_project_id='".$idShowcase."' AND showcase_gallery_type='image' ORDER BY showcase_gallery_index ASC"); $result = $query->result(); return $result; }
그리고 뷰 측면 I에 일부 아약스 있습니다 :
function ajaxFileUploadImage(){ $("#loading") .ajaxStart(function(){ $(this).show(); }) .ajaxComplete(function(){ $(this).hide(); }); $.ajaxFileUpload ( { url:'<?=site_url('ajaxadmin/showcase_image')?>', secureuri:false, fileElementId:'add_image', dataType: 'json', data:{}, success: function (data, status) { //jQuery('.thumb_file').attr('src','<?=base_url()?>resources/media/our_work/thumb/'+data.file); //jQuery('input[name=thumb]').val(data.file); var image = ' \ <div class="list" style="float:left;position:relative;margin-left:10px;margin-top:10px;"> \ <div class="description_img"> \ <div class="delete_img"></div> \ </div> \ <img height="100" src="<?=base_url()?>resources/media/showcase/image/'+data.file+'" style="z-index: 0; position: relative;"/> \ <div class="move_arrows"> \ <div class="move_on_left"></div> \ <div class="move_on_right"></div> \ </div> \ <input type="hidden" name="image_filename[]" class="image_filename" value="'+data.file+'"/> \ </div> \ '; jQuery('#showcase_image').append(jQuery(image)); }, error: function (data, status, e){ jQuery('.response_mes').html('<span class="red">* please try again later!</span>'); } } ) return false; }
이 코드가 도움이 될 것입니다 희망 누군가가 어쩌면 경우 soultion 난 당신이 jQuery를 AjaxFileUpload 플러그인은 "있는 iFrame을 사용하는 here을 발견 사용하고 있으리라 믿고있어
그러나 ajaxfileupload로이 문제를 해결할 수 없습니까? 문제는 내가 프로젝트를 업로드해야하는 부분에서 완벽하게 작동하고 쇼케이스 용 사진을로드하려고 할 때 문제가되지 않는다는 것입니다. 한 부분에서 다른 부분으로 코드 복사를 시도했지만 동일한 결과가 나타납니다. –
기존 코드베이스를 사용하여 작업 할 수 있어야한다는 데 동의합니다. CodeIgniter에 들어오는 $ _POST 배열의 내용을 검사하여 모든 파일 업로드 세부 사항이 올바른지 확인 했습니까? – davidethell