我在CodeIgniter框架上创建了一个用户注册表单,以便用户可以注册到我的网站。现在唯一不起作用的是我无法上传个人资料图片。当我点击注册按钮时,我收到2个错误。我希望将个人资料图片上传到product_foto列。
这是我的查看文件:(register.php):
public function register() {
$config['upload_path'] = './upload/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$this->load->library('upload', $config);
$this->input->post('profiel_foto');
$data_upload_files = $this->upload->data();
$image = $data_upload_files['./upload/'];
//voeg gebruiker toe aan database
$data = array(
'voornaam' => $_POST['voornaam'],
'achternaam' => $_POST['achternaam'],
'email' => $_POST['email'],
'wachtwoord' => ($_POST['wachtwoord']),
'startdatum' => date('Y-m-d'),
'postcode' => $_POST['postcode'],
'huisnummer' => $_POST['huisnummer'],
'woonplaats' => $_POST['woonplaats'],
'beschrijving' => $_POST['beschrijving'],
'geboortedatum' => $_POST['geboortedatum'],
'geslacht' => $_POST['geslacht'],
'profiel_foto' => $image
);
$this->db->insert('users', $data);
$this->session->set_flashdata("success", "Uw account is nu geregistreerd, u kunt nu inloggen");
redirect("auth/register", "refresh");
}
这是控制器中的寄存器代码:
PHP Error was encountered
Severity: Notice
Message: Undefined index: ./upload/
Filename: controllers/Auth.php
Line Number: 131
Backtrace:
File: /home/ubuntu/workspace/application/controllers/Auth.php
Line: 131
Function: _error_handler
File: /home/ubuntu/workspace/index.php
Line: 315
Function: require_once
A Database Error Occurred
Error Number: 1048
Column 'profiel_foto' cannot be null
INSERT INTO `users` (`voornaam`, `achternaam`, `email`, `wachtwoord`, `startdatum`, `postcode`, `huisnummer`, `woonplaats`, `beschrijving`, `geboortedatum`, `geslacht`, `profiel_foto`) VALUES ('hallo', 'hallo', 'hallo@gmail.com', 'hallo', '2017-06-28', 'hallo', 'hallo', 'hallo', 'hallo', '2017-06-10', 'Man', NULL)
Filename: controllers/Auth.php
Line Number: 149
这些是我在尝试注册时遇到的两个错误:
it 'is to be a Hash Object' do
workbook = {name: 'A', address: 'La'}
expect(workbook.is_a?(Hash)).to be_truthy
end
答案 0 :(得分:0)
您的第一个错误是由以下原因引起的:
fg = '2017-20'
val = df.loc[df['flag'] == fg, '№'].values[0]
print (val)
391
df1 = pd.DataFrame({'№_new':np.arange(val, val+53)})
print (df1)
№_new
0 391
1 392
2 393
3 394
4 395
5 396
6 397
7 398
8 399
9 400
10 401
11 402
..
..
如上所述' ./ upload /'不是有效索引,也不是该数组中的现有索引。目前还不清楚你在哪里定义它。
下一步:这条线做什么?
$image = $data_upload_files['./upload/'];
下一步:调试:在插入之前检查你的数组$ data并检查它。
$this->input->post('profiel_foto');
阅读用户指南,正如我在上述评论中所说的那样...因为我不是在这里写给你的......那应该让你开始。