0

我正在尝试上传 CSV 并将其内容保存在数据库中以供以后处理。CSV 文件恰好在某个位置有一个 ASCII 字符。这是 CSV 中的单元格之一

inflatable?ÿtavel?ÿpillow

现在,当尝试使用 PHP(准确地说是 cakePHP)将此文件读入数据库时​​,file_get_contents()忽略第一个之后的所有内容ÿ

$fh = fopen($_FILES['uploadedFile']['tmp_name'], 'rb');            
$this->request->data['ChannelUpload']['data'] = file_get_contents($_FILES['uploadedFile']['tmp_name']);
4

1 回答 1

-1

检查 php.net:

  <?php
    function file_get_contents_utf8($fn) {
         $content = file_get_contents($fn);
          return mb_convert_encoding($content, 'UTF-8',
              mb_detect_encoding($content, 'UTF-8, ISO-8859-1', true));
    }
    ?>
于 2013-08-15T09:31:52.587 回答