当我在本地主机上运行时,它很好。上传到 server.one 后抛出错误 - 即上传目标文件夹似乎不可写。这是我的控制器-
function do_upload()
{
$path = './uploads/';
chmod($path,0777);
$config['upload_path'] = $path;
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$config['encrypt_name'] = TRUE;
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_form', $error);
}
else
{
$this->load->library('form_validation');
$data = array('upload_data' => $this->upload->data());
$pic_path= 'uploads/'.$data['upload_data']['file_name'];
$this->form_validation->set_rules('txt_title','Title','trim|required|xss_clean');
$this->form_validation->set_rules('category', 'Select Category', 'callback_select_validate');
$this->form_validation->set_rules('description','Description','trim|required|xss_clean');
if($this->form_validation->run() == FALSE)
{
redirect('upload');
}
else{
$title =mysql_real_escape_string(htmlentities($this->input->post('txt_title')));
$category = $this->input->post('category');
$description = mysql_real_escape_string(htmlentities($this->input->post('description')));
$this->load->model('user');
$suc_mesg=$this->user->insertPic($pic_path,$category,$title,$description);
$this->load->view('upload_success', $suc_mesg);
}
}
}
这是我的视图页面-
<?php
echo $error;
echo form_fieldset('Upload Category Pics');
echo form_open_multipart('upload/do_upload');
echo '</br>';
echo form_label('Title','title');
echo '<input type="text" size="30" name="txt_title" placeholder="Enter title to pic"/>';
echo '</br></br>';
echo form_label('Choose Category Pics', 'category');
$options = array(
'null' => '--Please Select--',
1 => 'Technology',
3 => 'Entertainment',
2 => 'Politics',
4 => 'Sports'
);
echo form_dropdown('category', $options, 'category');
echo "<br></br>";
echo form_label('Description','description');
$data = array(
'name' => 'description',
'id' => 'description',
'placeholder' => 'Enter description',
'rows' => '5',
'cols' => '40',
);
echo form_textarea($data);
echo '</br></br>';
echo form_label('Browse Pics','pics');
echo '<input type="file" name="userfile" size="20" />';
echo "<br></br>";
echo '<input type="submit" value="upload" />';
echo '</form>';
echo form_fieldset_close();
?>
我找不到我的错误,到底哪里错了。有人准备好帮助我吗?