在MySQL和命名约定中存储图像/数据 [英] Storing image/data in MySQL and naming conventions

查看:189
本文介绍了在MySQL和命名约定中存储图像/数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么想法在网络服务器上存储图像。 Im与应用程序的PHP和MySQL交互。

What are some ideas out there for storing images on web servers. Im Interacting with PHP and MySQL for the application.

文件到 a000000001.jpg 并将其存储在基本目录中或保留用户的非托管文件名,即Justin Beiber Found dead.jpg?例如

Do we change the name of the physical file to a000000001.jpg and store it in a base directory or keep the user's unmanaged file name, i.e 'Justin Beiber Found dead.jpg'? For example

wwroot/imgdir/a0000001.jpg

和数据库中的所有元数据,例如 FileName ReadableName Size 位置等。
我需要一个自定义Filemanager,

and all meta data in a database, such as FileName and ReadableName, Size, Location, etc. I need to make a custom Filemanager and just weighing out some pros and cons of the underlying stucture of how to store the images.

如何保护图像的基本结构的优点和缺点

How would I secure an Image from being downloaded if my app/database has not set it to be published/public?

在我的应用程序中,我可以发布图片或保护他们免于下载,如果我的应用程序/数据库没有将其设置为发布/公开?我将图像存储在数据库表中,我可以将其存储为BLOB,并使用PHP阻止用户下载它。我想要能够做同样的图像,如果它是存储在文件系统,但我不能确定这是可能与PHP和系统中的文件。

In my app I can publish images, or secure them from download, if I stored the image in a db table I could store it as a BLOB and using php prevent the user from downloading it. I want to be able to do the same with the image if it was store in the FileSystem, but im not sure if this is possible with PHP and Files in the system.

推荐答案

保存相关的文件名可能对SEO有好处,但您还必须确保不重复。

Keeping relevant file names can be good for SEO, but you must also make sure you don't duplicate.

Justin Beiber发现dead.jpg 我们将文件重命名为小写并用下划线=> justin_beiber_finally_dead.jpg

Justin Beiber Found dead.jpg => justin_beiber_finally_dead.jpg

如果照片属于某篇文章或特定内容,您可以添加文章ID到图像,即 123_justin_beiber_found_dead.jpg 。或者,您可以将图像存储在文章特定的文件夹中,即 /images/123/justin_beiber_found_dead.jpg

If the photo's belongs to an article or something specific you can perhaps add the article ID to the image, i.e. 123_justin_beiber_found_dead.jpg. Alternatively you can store the images in an article specific folder, i.e. /images/123/justin_beiber_found_dead.jpg.

命名 a0000001 的文件会删除与文件的所有相关性,并且不会添加任何值。

Naming the files like a0000001 removes all relevance to the files and adds no value whatsoever.

对于第2部分;

我不知道这里最好的解决方案是什么,但是使用文件系统,我想你将必须配置apache来通过PHP提供特定目录中的所有文件。在PHP中,您可以检查文件是否可以发布,然后吐出来。如果没有,您可以提供虚拟图像。然而这不是很有效率,并且对apache更重。

I'm not sure what the best solution here is, but using the filesystem, I think you will have to configure apache to serve all files in a particular directory by PHP. In PHP you can then check if the file can be published and then spit it out. If not, you can serve a dummy image. This however is not very efficient and will be much heavier on apache.

这篇关于在MySQL和命名约定中存储图像/数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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