0
我有一個應用程序,neede照片上傳,已在codeigniter中完成,在本地主機上正常工作,但它不能在線工作。Codeigniter圖像上傳不能在線工作
查看網頁代碼:
<div>
<form id="uploadimage" method="POST" name="uploadimage" action="<?php echo base_url(); ?>onebachhpan/savephoto" enctype="multipart/form-data">
<input type="file" name="userfile" id="userfile" accept="image/*" /><br/><br/>
<input type="submit" class="button_example" id="upload_button" name="upload_button" value="Upload"/>
</form>
<br/>
<form id="removeimage" method="POST" name="removeimage" action="<?php echo base_url(); ?>onebachhpan/removephoto" enctype="multipart/form-data">
<input type="submit" style="position: absolute; left: 100px; top: 64px; " class="button_example" id="delete_button" name="delete_button" value="Delete"/>
</form>
</div>
以下爲圖片上傳控制器代碼: 這是工作的罰款在localhost:
控制器代碼:
function savephoto()
{
$this->load->library('session');
$this->load->library('image_lib');
$config['image_library'] = 'gd2';
$config['upload_path'] = './profilepic/'; //location to store image
$config['allowed_types'] = 'gif|jpg|png';
$this->load->library('upload', $config);
if (! $this->upload->do_upload('userfile'))
{
$error = array('error' => $this->upload->display_errors());
redirect(base_url().'uploaderror');
}
else
{
$photo = $this->upload->data();
$data['photo'] = $photo;
$id = $this->session->userdata('MemberId');
$filename = $photo['file_name'];
$extension = $photo['file_ext'];
$this->load->model('profile_model');
$this->profile_model->photo($extension,$id);
// echo "<pre>";print_r($photo);
$newpath = './profilepic/'.$id.$extension;
$config['source_image'] = './profilepic/'.$filename;
$config['overwrite']=true;
$config['new_image'] = $newpath;
$config['width'] = '170';
$config['height'] = '240';
$config['maintain_ratio'] = true;
//$this->load->library('image_lib', $config);
$this->image_lib->initialize($config);
$this->image_lib->resize();
unlink('./profilepic/'.$filename);
//$this->load->view('onebachhpan_index');
redirect(base_url().'profile');
}
}
你有什麼試圖解決這個問題的?控制器中$ _FILES的值是多少?你是否打開錯誤報告來查看發生了什麼問題? – mcryan 2013-03-08 07:49:11
我上傳單個文件,因此我不需要$ _FILES,上面的代碼在localhost上工作也很完美,但是當我將它部署到在線服務器時,photouploading無法正常工作......您可以在[link] (http://one.bachhpan.org/) – 2013-03-08 08:40:39
如果您上傳單個文件或多個文件,則會將數據發送到PHP的$ _FILES變量。 http://php.net/manual/en/reserved.variables.files.php – mcryan 2013-03-08 08:49:39