如何将主题与 css/js/images/pdf 文件一起保存到数据库中?

发布于 2024-10-28 10:21:33 字数 591 浏览 2 评论 0原文

我正在尝试弄清楚如何做到这一点。或者我是否应该使用物理磁盘来存储我的所有文件。

我希望能够将我为我的网站制作的主题保存到我的数据库中(我正在使用我自己的框架)我最初制作主题时将它们放在自己的文件夹中并将它们上传到主题文件夹中,但从那时起我重新设计了我的网站,让其他人创建帐户并让他们制作自己的主题并保存以供以后使用。

我现在使用 SMARTY 模板引擎,所以现在我有 1 个名为 tpl 的文件夹,在该文件夹中我有一些模板文件。

标记.tpl site.tpl

和 css.php 和 js.php

这些我希望能够从数据库加载到 css/js 中。

但我的问题是,CSS 文件中可能引用了 50 张图像,如何将这些图像与 CSS 文件一起保存?

我不知道什么会更容易管理,使用一些散列文件名上传到我的服务器的图像或将图像保存到数据库中。如果图像在数据库中,是否会更容易管理和组织?如果用户删除了他们的帐户怎么办,我需要找到所有主题文件并将它们一一删除,尤其是图像。我想如果文件位于服务器上,那么删除链接到其唯一 ID 的行会容易得多...

无论如何,我正在尝试找到最好的方法,以减轻服务器上的压力或修改主题通过我的在线编辑器保存文件更简单。

I'm trying to figure out how to do this. Or if I should use the physical disk to store all my files.

I want to be able to save themes that I make for my site to my database (i'm using my own framework) I originally was making themes in placing them in their own folder and uploading them to a themes folder, but since then I have redone my site to let other people create accounts and let them make their own themes and save them for later use.

I'm now using SMARTY template engine so now I have 1 folder called tpl and in that folder I have a few template files.

markup.tpl
site.tpl

and css.php
and js.php

these I hope will load in the css/js from the database.

But my issue is that in the CSS file there could be references to 50 images, how can I save those images along with the CSS file?

I didn't know what would be easier to manage, images uploaded to my server with some hashed filename or have the images saved onto the database. If the images are in the database would it be easier to manage and organize? What if a user deletes their account, I would need to hunt down all the theme files and delete them one by one, especially the images. I imagine if the files are on the server, then deleted the rows that link to their unique ID would be alot easier...

Anyways, I'm trying to find the best method that would have less stress on my server or make modifying themes files via my online editor simpler when saving.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北方的巷 2024-11-04 10:21:33

不要忘记 MySQL BLOB 列的大小是有限制的,因此文件需要分成多行。我觉得总的来说,文件系统似乎是为了处理文件操作而编写的,它是文件的最佳位置。

当您有需要搜索或操作的文本时,数据库非常有效。它们对于二进制文件没有那么有效。

Don't forget there is a limit to the size of MySQL BLOB columns so files would need to be broken over multiple rows. I feel in general that seeing as though the file system was written to handle file operations it is the best place for files.

Databases are effective where you have text that you need to search or operate against. They are not as effective with binary files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文