Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
User avatar is an important part of every website. How should I store the avatar image files on the server with high performance?
Here are some points have to solve:
How to generate the file name of user? Directly by user id or name,
or by the hashed/md5 id/name?
How to storage the file? All in one dictionary or in different dictionary (How to?).
The avatar file can cacheable if the link of the file is permalink, but what if the user change the new avatar?
Personally, I store a text field in the user's database row, of the format:
WWW|HHH|URL
The width and height (WWW and HHH) are fetched when the user selects the file, and the URL is simply the address where the avatar can be found.
You actually save a huge amount of bandwidth by not putting user's avatars on your servers.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
How could I store my media files (pictures, videos etc)? I am building a simple web app like a social website ,using php. I don't really know how could I save my pictures in a datbase for the moment when I log in with a certain user, i can see all his data (pictures, etc). And how could I link more pictures, for example if I have a "add image" button in the middle of page, i want to upload as more photos as i want, and for every photo using a storage method.
You'll want to store the image names in a database.
For example -
You could create a table in the database called "posts" or "images" and store the image file name in the table and associate it to the user who uploaded it.
Example table structure could be: id, user_id, image_name
You will then write a query to get the images by the users ID stored in that table.
It's fairly simple and I've done it many times.
I hope this helps.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
is there a way to upload a file that the user have uploaded before into the database? eg, you have uploaded a resume into your own profile page (online) and now, you would like to send this same resume (online) to another person by uploading to the same website. however, it has to be chosen from your profile page
It is possible, but pointless. As #Mubin Khalid said, you should store these resources as files and store their path in the database. The file can be accessed through its path and you need to load only that from the database. If you want to duplicate files, then you have serious problems with the design of your database.
You need to have a table for resources, like this: resources(id, path). Naturally, based on your business logic, you might need other columns, like resource_type or owner. To handle attachments, you need to tackle with the n:m relation types using intermediate tables, which will have a foreign key which references resources(id).
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Background
I'm creating a website where the user can store an article as a file in the database and than upload the file's content into a page in the website using a form. The file may only contain text or image or both.
Question
Can anyone walk me through this?
I would suggest you to create a database table having fields having the userId, and path of the file.
The file uploaded should be saved in the Web Server, and its path need to be saved in the database.
The vice-versa should be done while retrieving the file content.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Okay so I am doing this project and i need to allow the user the ability to upload 6 images, how should i go by doing this on the database side of things.
Make a column for each image
Store it in one column as an array and then do the processing of the array with PHP?
I will be useing the Yii Framework and also MySQL as a database engine.
I know how to upload file and store it to a directory and the other needed things, just not sure what to tackle the problem.
EDIT: My final goal is to have this index page edited by one user (Admin) and I want him to allow him to edit the images and the current offers as well.
You should create table user_images beacause:
You can change number of images pef user in the future without changing database
You can easily display all images in GridView and easly generate CRUD for user images.
You can easily store versioned list of images for user.
Implementation and code reusable will be simplier.
You should create a new table called "user_images(id, user_id, image_url)" to store image.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have built a login application (App), and I'm thinking of implementing another feature.
I want to show users specific content depending on which user is logged in. For example, say I'm user "Dream". When I log in, I should only see the files that are related to me, such as my downloads, images, and so on.
How could I implement this?
If you have data in database, users has probably its own ID. Personalized content, as images for example, then has to have user ID mark (it creates logic connection). After user is logged, save its ID into session. After he show page with images, pick up user ID form session, select images with user ID mark from database and display them.
If your data are not in database, principle will be the same.