这是我的错误:
注意:未定义的索引:第21行的C:\ xampp\htdocs\Project\Template1\users\index.php中的文件注意:未定义的索引:C:\ xampp\htdocs\Project\Template1\users\index.php中的文件第23行请上传
如何摆脱它?
Html代码:
<form action="index.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" id="file"><br><br>
<input type="submit" value="submit" name="submit">
</form>
Run Code Online (Sandbox Code Playgroud)
PHP代码:
<?php
$name = $_FILES['file']['name'];
$temp_name = $_FILES['file']['temp_name'];
if (isset($name)) {
if (!empty($name)) {
$location = '../uploads/';
}
if (move_uploaded_file($temp_name, $location.$name)) {
echo 'uploaded';
}
} else {
echo 'please uploaded';
}
?>
Run Code Online (Sandbox Code Playgroud) 致命错误:使用codeIgniter调用未定义的函数validation_errors()这是我的comments.php视图
<?php echo validation_errors(); ?>
<?php echo form_open('news/comments'); ?>
Name <input type="text" name="comment_name"></input><br />
Email <input type="text" name="comment_email"></input><br />
Comment<input type="text" name="comment_body"></input><br />
<input type="submit" name="submit" value="Comment it" ></input>
</form>
Run Code Online (Sandbox Code Playgroud)
这是我的news_model.php
<?php
class News_model extends CI_Model {
public function __construct()
{
$this->load->database();
}
//set comment
public function set_comment()
{
$this->load->helper('url');
$this->load->helper('date');
$data_c = array(
'comment_name' => $this->input->post('comment_name'),
'comment_email' => $this->input->post('comment_email'),
'comment_body' => $this->input->post('comment_body'),
);
return $this->db->insert('comments', $data_c);
}
Run Code Online (Sandbox Code Playgroud)
}
在这里我的控制器news.php
<?php
class News extends CI_Controller { …Run Code Online (Sandbox Code Playgroud)