こんにちは、これは簡単な質問ですが、エラーが表示されていないことを理解するのに十分な時間、それを見つめてきました。誰かがこれがどこで間違っているのかを見ることができれば、私は非常に感謝しています.
public function create()
{
$this->load->model('ticket_model');
if($_POST)
{
// validate form
if($this->_validate())
{
// save updates
foreach($_POST as $key => $value){if(!is_array($value)) $_POST[$key] = htmlspecialchars($value);}
if ($_POST['subject'] == '') $body_data['error'][] = "You did not enter a subject.";
if ($_POST['priority'] == '') $body_data['error'][] = "You did not select a priority.";
if ($_POST['status'] == '') $body_data['error'][] = "You did not select a status.";
if ($_POST['ipAddress'] == '') $body_data['error'][] = "You did not enter a ipAddress.";
if ($_POST['text_area'] == '') $body_data['error'][] = "You did not enter a message.";
else
{
if (filter_var($_POST['ipAddress'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) == FALSE) $body_data['error'][] = "IP Address is not valid IPV4 Address.";
if (filter_var($_POST['ipAddress'], FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE) == FALSE) $body_data['error'][] = "IP Address cannot be from RFC1918 private space.";
if (filter_var($_POST['ipAddress'], FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) == FALSE) $body_data['error'][] = "IP Address cannot be from reserved range.";
}
if ($_FILES['filename']['name'] != '')
{
if ($_FILES['filename']['size'] > '1024000')
{
$body_data['error'][] = "The file you uploaded is too large.";
unlink($_FILES['filename']['tmp_name']);
$body_data['ticket_list'] = $this->ticket_model->list_ticket();
$body_data['ticket_details'] = $this->ticket_model->get_ticket($ticket_id);
$body_data['ticket_summary'] = $this->ticket_model->list_ticket_summary($ticket_id);
$body_data['precan_list'] = $this->ticket_model->list_messages();
$body_data['users_list'] = $this->ticket_model->list_users();
$foot_data['accordian_active'] = 5;
$this->load->view('head',$head_data);
$this->load->view('sidebar/service',$head_data);
$this->load->view('ticket/edit',$body_data);
$this->load->view('foot',$foot_data);
return;
}
else
{
//the file is under the specified size. so copy it from temp to import folder and proccess
$thisFileHumanName = $_FILES['filename']['name'];
$thisFileSize = $_FILES['filename']['size'];
$thisServerFileName = strtoupper(uniqid('A'));
$thisFileType = $_FILES['filename']['type'];
$temp_file_location = $this->config->item('rootpath').'/assets/ticketuploads/'.$thisServerFileName;
if (!move_uploaded_file($_FILES['filename']['tmp_name'], $temp_file_location))
{
$body_data['error'][] = "File could not be moved due to a permissions error.";
unlink($_FILES['filename']['tmp_name']);
$body_data['ticket_list'] = $this->ticket_model->list_ticket();
$body_data['ticket_details'] = $this->ticket_model->get_ticket($ticket_id);
$body_data['ticket_summary'] = $this->ticket_model->list_ticket_summary($ticket_id);
$body_data['precan_list'] = $this->ticket_model->list_messages();
$body_data['users_list'] = $this->ticket_model->list_users();
$foot_data['accordian_active'] = 5;
$this->load->view('head',$head_data);
$this->load->view('sidebar/service',$head_data);
$this->load->view('ticket/edit',$body_data);
$this->load->view('foot',$foot_data);
return;
}
}
}
//clean error array
$body_data['error'] = array_filter($body_data['error']);
if ($body_data['error'])
{
$body_data['ticket_list'] = $this->ticket_model->list_ticket();
$body_data['ticket_details'] = $this->ticket_model->get_ticket($ticket_id);
$body_data['ticket_summary'] = $this->ticket_model->list_ticket_summary($ticket_id);
$body_data['precan_list'] = $this->ticket_model->list_messages();
$body_data['users_list'] = $this->ticket_model->list_users();
unlink($_FILES['filename']['tmp_name']);
$foot_data['accordian_active'] = 5;
$this->load->view('head',$head_data);
$this->load->view('sidebar/service',$head_data);
$this->load->view('ticket/edit',$body_data);
$this->load->view('foot',$foot_data);
return;
}
else
{
$_POST['userId'] = $this->session->get_user_id();
$thisMessageId = $this->ticket_model->save_message($_POST);
if ($_FILES['filename']['name'] != '')
{
//set variables for save
$_POST['file_path'] = $temp_file_location;
$_POST['file_name'] = $thisFileHumanName;
$_POST['file_size'] = $thisFileSize;
$_POST['file_type'] = $thisFileType;
$_POST['messageId'] = $thisMessageId;
$this->ticket_model->save_upload($_POST);
}
$this->ticket_model->save_ticket($_POST);
redirect(base_url().'ticket/');
return;
}
}
}
$body_data['ticket_list'] = $this->ticket_model->list_ticket();
$body_data['message_list'] = $this->ticket_model->list_message($ticket_id);
$body_data['customer_list'] = $this->ticket_model->list_customers();
$body_data['users_list'] = $this->ticket_model->list_users();
$foot_data['accordian_active'] = 5;
$foot_data['contact_search'] = true;
$this->load->view('head',$head_data);
$this->load->view('sidebar/service',$head_data);
$this->load->view('ticket/create',$body_data);
$this->load->view('foot',$foot_data);
return;
}
これは私のコードであり、アップロードを保存するセクションを除いて、すべてがうまくいっています。送信元から投稿されたファイルがあり、そこに投稿されているファイル名があるとはいえ、モデルを起動していないようです。!= ''
……例えば
if ($_FILES['filename']['name'] != '')
{
//set variables for save
$_POST['file_path'] = $temp_file_location;
$_POST['file_name'] = $thisFileHumanName;
$_POST['file_size'] = $thisFileSize;
$_POST['file_type'] = $thisFileType;
$_POST['messageId'] = $thisMessageId;
$this->ticket_model->save_upload($_POST);
}
これがばかげた間違いである場合、私の謝罪。