How can a website record the uploaded image url?

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.