Symfony-从请求中存储图像
我正在制作具有添加帖子功能的应用程序。每个帖子都有可能包含图像。我的主要问题是我不知道如何存储图像。我知道我可以创建一个名为“私有”的单独文件夹,但事实是,它应该具有一定的结构来不将所有图像放在一起。我想避免在一个文件夹中拥有数千张图像。我在某个地方看到了人们制作文件夹结构的地方,然后以某种方式决定应存储每个图像的位置(例如,用原始文件名)。这看起来像这样:
private:
15:
23:
image_file.jpg
88:
image_file2.jpg
13:
48:
image_file3.jpg
有没有办法在Symfony中执行这种文件结构?我唯一的解决方案是以某种方式将文件名转换为数字,然后使用Modulo。但是我认为这不是一个好主意。
I am making an app with a feature of adding posts. Every post have the possibility to contain an image. My main problem is the thing I don't know how to store the images. I know I can create a seperate folder named for example "private" but the thing is it should have some structure to not put all images together. I would like to avoid having thousands of images in one folder. I've seen somewhere that people make a structure of folders then somehow decide where each image should be stored (for example by original file name). This looks something like this:
private:
15:
23:
image_file.jpg
88:
image_file2.jpg
13:
48:
image_file3.jpg
Is there a way to do this kind of file structure in Symfony? The only solution that I have in my mind is somehow transforming filenames into numbers then using modulo. But I don't think it is a good idea.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将您的帖子ID纳入路径:
Simply incorporate your Post ID into path: