在PHP中存储文件结构 [英] Storing file structure in PHP

查看:85
本文介绍了在PHP中存储文件结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将文件结构与文件(例如来自Zip文件)一起存储的最佳方法是什么?当前,每个文件在MySQL数据库中都是一行,但是显然无法从中读取任何结构.我想避免存储二进制文件.所有文件应为纯文本.每个zip/文件结构对于提交它的用户都是私有的.

What is the best way to store a file structure, along with files, say from a Zip file? Currently each file is a row in the MySQL database, but obviously no structure can be read from that. I want to avoid storing a binary file. All files should be plain text. Each zip/file structure is private to the user whom submitted it.

推荐答案

如果要结构化,可以有一个目录表和一个文件表.然后,对于根目录中的每个目录,其父ID为0.然后,该目录下的每个目录均具有其父目录的父ID.

If you want structure, you could have a directory table and a file table. Then for each directory in the root would have a parent id of 0. And then each directory under that have the parent id of it's parent.

然后,为文件提供目录ID,以指示它们的位置.

Then you give the files directory id's to indicate where they are.

这篇关于在PHP中存储文件结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆