How can we record the storage address of each uploaded image file after the image is uploaded to the server? For example, how do we record uploaded images, photo albums, product images, and so on? 1: for example, if a user table has an image uploaded from a website, how can we record the storage address of each uploaded image file after the image is uploaded to the server?
For example, how do we record uploaded images, photo albums, product images, and so on?
1: for example, a user table hasAvatarField, the user uploads the image, and then save the image url, such as: http://www.thinkphp1.cn/Uploads/da/2015-08-05/55c18ef67e249.jpgAvatarField? Or do I save only the image name or split it into three fields: Domain name/path/name?
2: There are also user albums. users upload many images. how can I save the image url in the database?
3: There is also a post in the DZ forum that may contain many images. how can this problem be saved? do you still need to create an image attachment table separately and associate it with the Post ID?
4: If cloud storage is used, such as Qiniu and upyun, will an image url be returned to you after being uploaded using their interfaces? So do we save the returned image url in the database as above?
Since the image upload function is used in many parts of the website, the location of each uploaded image on the server must be recorded, why don't we create a table to save all uploaded image URLs?
The simplest design of this table I think of: imgup (id, url)
This is simple. all uploaded image information is recorded here, for exampleAvatarThe image url is saved, and the corresponding id can be saved now, which is much simpler, such as product images, post content images ,......, The same is true.
But I always think this is too simple and inappropriate. how can we design this table most rationally? You do not need to add any other information, such as the original name, image size, image size, image creation time, image modification time, and Image EXIF information before the client is uploaded, ...... And so on.
I have not read the DZ code. I can see every attachment image and other files in my post, and have control permissions for users to download. I don't know how it works.
This problem is extended to the website [file Upload] and is not limited to images. all uploaded file information is stored in the table that records the uploaded file information, which is much more convenient, management is also convenient, so I have been thinking about this for a long time, that is, I have no experience, so I would like to consult with you.
I hope that experienced experts will give us some advice and give me some advice. thank you!
Reply content:
How can we record the storage address of each uploaded image file after the image is uploaded to the server?
For example, how do we record uploaded images, photo albums, product images, and so on?
1: for example, a user table hasAvatarField, the user uploads the image, and then save the image url, such as: http://www.thinkphp1.cn/Uploads/da/2015-08-05/55c18ef67e249.jpgAvatarField? Or do I save only the image name or split it into three fields: Domain name/path/name?
2: There are also user albums. users upload many images. how can I save the image url in the database?
3: There is also a post in the DZ forum that may contain many images. how can this problem be saved? do you still need to create an image attachment table separately and associate it with the Post ID?
4: If cloud storage is used, such as Qiniu and upyun, will an image url be returned to you after being uploaded using their interfaces? So do we save the returned image url in the database as above?
Since the image upload function is used in many parts of the website, the location of each uploaded image on the server must be recorded, why don't we create a table to save all uploaded image URLs?
The simplest design of this table I think of: imgup (id, url)
This is simple. all uploaded image information is recorded here, for exampleAvatarThe image url is saved, and the corresponding id can be saved now, which is much simpler, such as product images, post content images ,......, The same is true.
But I always think this is too simple and inappropriate. how can we design this table most rationally? You do not need to add any other information, such as the original name, image size, image size, image creation time, image modification time, and Image EXIF information before the client is uploaded, ...... And so on.
I have not read the DZ code. I can see every attachment image and other files in my post, and have control permissions for users to download. I don't know how it works.
This problem is extended to the website [file Upload] and is not limited to images. all uploaded file information is stored in the table that records the uploaded file information, which is much more convenient, management is also convenient, so I have been thinking about this for a long time, that is, I have no experience, so I would like to consult with you.
I hope that experienced experts will give us some advice and give me some advice. thank you!
No one answered?
1. the external link of UPYUN is in the form of http: // <space name> .b0.upolicyun.com/ <文件路径>
# <文件路径> You can define it by yourself. For more information, see save-key.
2. refer to the official SDK
3. DZ has official plug-ins. you can refer to [DZ].
4. same as 2
I am also working on a similar platform. I am using nodejs to process all file requests. The naming method is uid/year-month/hash. Qiniu can check whether your bucket is private. if not, you can directly splice the bucket domain name. For private space, you can use the sdk to obtain files temporarily. Phone calls, a little messy. sorry.