[英]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
uploadtable
(idlink
,nama
,tipe
,ukuran
)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.