duanguoping2016 2014-07-10 15:59
浏览 27

在zip中插入的井号的文件名在mysql数据库中作为空白插入

I have a zip file (A.zip) having multiple files in it. When I am trying to insert the filenames in my database field, it is getting inserted as blank in one of the fields.

Here is the code I am using:-

    $filename = "A.zip";
    $zip = zip_open($filename); 
    if ($zip) {
        while ($zip_entry = zip_read($zip)) {
            $zip_file_name = zip_entry_name($zip_entry);
            $zip_file_name = preg_replace("/([!?:%,\[\]@{+;}=*<>~#\"^&*|()\\/])/", " ",$zip_file_name);
            // Every single time, the file name is read, it is inserted in the database

    }
    zip_close($zip);
}

filenames in zip file:- 1) 178_!£$%^&&@{~~.xslx 2) 128_!£$%^@{~.xslx

I am replacing all the required special characters with the space (" "), but need to keep dollar ($) and pound (£) in the filename (when inserted).

Now, what is happening, all the required characters are correctly getting replaced with spaces and $ is also correctly placed, but when it comes to pound sign (£), it is getting replaced with a black diamond question mark (when I did console log) and a blank filename is getting inserted in the database.

When single file is inserted in the database, it is getting correctly inserted with the $ and pound(£) sign.

field name in the database is varchar(255) with utf8_general_ci as collation.

Also, the meta tag is set as charset UTF-8: -

I have tried looking out for solutions over the internet, but couldn't able to find the one related with zip file.

Just to note: All filenames with simple english characters and numbers are correctly getting inserted into the database.

Also, when I remove the pound sign (£), filename is correctly inserted..

Please..Any help is appreciated!!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私
    • ¥15 ROS系统搭建请教(跨境电商用途)
    • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。