How to store .txt files MySQL database?

前端 未结 4 2064
清歌不尽
清歌不尽 2021-01-02 18:36

Can I store data files (e.g. txt files) to the MySql server? If I can, how to store them?

4条回答
  •  死守一世寂寞
    2021-01-02 19:13

    Sure you can. I would suggest reading the data from your files and then saving it in your database, i would say in a text field.

    You can use something like this to get the file's content:

    $file = file_get_contents('./yourfile.txt');
    

    Then insert it

    Insert into myTable VALUES (mytextfile = $file)
    

提交回复
热议问题