第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

無(wú)法打開流:沒(méi)有這樣的文件或目錄 Codeignter

無(wú)法打開流:沒(méi)有這樣的文件或目錄 Codeignter

PHP
開心每一天1111 2021-11-05 15:15:54
我正在嘗試將數(shù)據(jù)從 csv 文件上傳到我的 sql server 數(shù)據(jù)庫(kù)。所以我創(chuàng)建了這個(gè) csv 閱讀器庫(kù):<?phpif (!defined('BASEPATH')) exit('No direct script access allowed');class CSVReader{    var $fields;    /** columns names retrieved after parsing */    var $separator = ';';    /** separator used to explode each line */    var $enclosure = '"';    /** enclosure used to decorate each field */    var $max_row_size = 4096;    /** maximum row size to be used for decoding */    function parse_file($p_Filepath)    {        $file = fopen($p_Filepath, 'r');        $this->fields = fgetcsv($file, $this->max_row_size, $this->separator, $this->enclosure);        $keys_values = explode(',', $this->fields[0]);        $content    =   array();        $keys   =   $this->escape_string($keys_values);        $i  =   1;        while (($row = fgetcsv($file, $this->max_row_size, $this->separator, $this->enclosure)) != false) {            if ($row != null) { // skip empty lines                $values =   explode(',', $row[0]);                if (count($keys) == count($values)) {                    $arr    =   array();                    $new_values =   array();                    $new_values =   $this->escape_string($values);                    for ($j = 0; $j < count($keys); $j++) {                        if ($keys[$j] != "") {                            $arr[$keys[$j]] =   $new_values[$j];                        }                    }                    $content[$i] =   $arr;                    $i++;                }            }        }        fclose($file);        return $content;    }    function escape_string($data)    {        $result =   array();        foreach ($data as $row) {            $result[]   =   str_replace('"', '', $row);        }        return $result;    }}?>然后我試圖從文件中開始對(duì)我的數(shù)據(jù)檢索部分進(jìn)行編碼,以便我可以將它們發(fā)送到模型以便將它們插入到數(shù)據(jù)庫(kù)中。但我收到此錯(cuò)誤:無(wú)法打開流:沒(méi)有這樣的文件或目錄這是指向fopen指令。你能幫我解決這個(gè)問(wèn)題嗎?
查看完整描述

1 回答

?
函數(shù)式編程

TA貢獻(xiàn)1807條經(jīng)驗(yàn) 獲得超9個(gè)贊

因?yàn)槟鷽](méi)有指向完整路徑(包括文件夾)


嘗試


<?php

 $data = $this->upload->data();

    //$csvFile=FCPATH."upload/".$fileName; //php way (uploaded filepath and filename )

  $csvFile=$data['full_path']; //codeigniter way

  $result =   $this->csvreader->parse_file($csvFile);


?>


查看完整回答
反對(duì) 回復(fù) 2021-11-05
  • 1 回答
  • 0 關(guān)注
  • 151 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)