繁体   English   中英

PHP MySQL 使用 Codeigniter-3 + Dropzone-4.1 使用 $_GET 方法插入表数据库

[英]PHP MySQL insert into table database with $_GET method using Codeigniter-3 + Dropzone-4.1

在 CodeIgniter 3 上工作,并在“id_case”上遇到问题。 它说未定义的索引:id_case。

当我单击index.php 中的链接时

<?php echo "<td><a href='/ci_dropzone/?id_case=".$row['id_case']."'>Upload File To This ID</a></td>";?>

然后我使用codeigniter 3 + Dropzone-4.1,在文件中说控制器文件夹中的upload.php有:

<?php require 'conn.php'; <== i add this linker
if (!defined('BASEPATH'))exit('No direct script access allowed');


class Gambar extends CI_Controller {
    private $datauser;
    function __construct() {
        parent::__construct();
        $this->load->helper(array('url','file'));
    }

    function index(){
        $data['js'] = base_url('assets/js');
        $data['css'] = base_url('assets/css');
        $data['img'] = base_url('assets/images');

        $this->load->view('gambar', $data);
    }

    function gambar_upload() {

        if (!empty($_FILES)) {
            $tempFile = $_FILES['file']['tmp_name'];
            $fileName = $_FILES['file']['name'];
            $fileType = $_FILES['file']['type'];
            $fileSize = $_FILES['file']['size'];
            $filelink = $_GET['id_case']; <== i add this line
            $targetPath = './assets/uploads/';
            $targetFile = $targetPath . $fileName ;

            move_uploaded_file($tempFile, $targetFile);

            $this->db->insert('uploadtable', array( 'idlink' => $filelink, 'nama' => $fileName, 'tipe' => $fileType, 'ukuran' => $fileSize));
        }
    }
}?>

我努力了如何使用函数$ _GET获得id_case号码,以便亚姆能够无标签自动使用id_case数量<form>并提交以便插入在idlink表列的数据库uploadtable。 错误显示如下:

遇到 PHP 错误

严重性:注意

消息:未定义索引:id_case

文件名:controllers/upload.php

行号:32

回溯:

文件:E:\\controlX\\htdocs\\ci-dropzone\\application\\controllers\\upload.php 行:32 功能:_error_handler

文件:E:\\controlX\\htdocs\\ci-dropzone\\index.php 行:294 功能:require_once 发生数据库错误

错误编号:1048

列“idlink”不能为空

INSERT INTO uploadtableidlinknamatipeukuran )VALUES(NULL, '10000000000257660_1920x1080.jpg', '图像/ JPEG',1257381)

文件名:E:/controlX/htdocs/ci-dropzone/application/controllers/upload.php

行号:38

我该如何解决这个问题?

你在构造函数中尝试过吗?

如;

function __construct() {
    $this->case_id = isset($_GET['case_id']) ? $_GET['case_id'] : null;
}

这应该是工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM