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.
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 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 8 years ago.
Improve this question
I'm creating a android chat application with a basic layout and hosted in a php hosting service and mysql as my back end. I'm retrieving the user details using JSON from server to update my user lists. Now these are my issues regarding profile pics
But now I wanna store profile image of the user. I really have no idea of storing profile pics. Becoz other people have mentioned that storing image in the mysql table would bring down the performance of the db system. Which is efficient way to do this?
While retrieving image (weather it is in mysql or server), I don't want to load profile pics each time. What can be done for this issue ?
I worked on the same project once
1 - The best way to store profile pictures is to do it like Viber and Whatsapp store them in the internal memory or external if there is any available space of course
2- well you need to cache your photos once loaded the first time and then just load them from the cached version if there is any modification then you apply the new photo in place of the cached one and cache it again
[EDIT]
After your comment I understand that you're using mysql to store chat messages and profile pictures, so you can go this way :
you store the images in the mysql database within your server and for every user you download his friends pictures then cache and store them in the sdcard.
for every new user you ask him to upload his picture to your database then his friends will download it back.
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
i want to be able to upload multiple images (i got this working) its array
only problem is i need each image to have its own content but i want to use one form as this relates to a specific article.As you see this picture
This welcome article for example has a heading, an image and text to explain for each image .
this is my current db structure but as you can see there is no way content will be separate for each image
article id is the foreign key
How could i achieve this in a database structure?
You talking about uploading images to your server right ? if so:
You got few options to do it:
Create a 'unique' id and put them inside the image element and the content element.
Then you will get two arrays and you combine them by the unique.
Almost the same, just simply to store the content and the images inside arrays. and just loop through them and 'combine' them by the array's id. because you inserting the same amount so it should be the same. But answer 1 is safer here.
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 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.