/    Sign up×
Community /Pin to ProfileBookmark

Images for USER profile

I have a website for property listing in India. I have list of registered users. Presently , all fields are text and numeric data. Now I want to add User Images, Photos to the user data. How an I do it. Front end is PHP. Backend is My SQL. I am not using any framework. ?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmMar 19.2015 — Add file upload capability to your web page and store the image files somewhere on your server. Do not put them into a database table. Simply make a folder for images and either label them with the user id and a sequential number or create a file name that you store in a db table linked to the user.


Example table structure:

userid

filename (matches name of stored image file)

date_uploaded

description

To retrieve the images use your db table by searching for all records belonging to the userid or search the image file folder for filenames beginning with the userid if you used that method of naming. You could also create individual folders for each registered user if you want to separate the files that way.
Copy linkTweet thisAlerts:
@rootMar 22.2015 — You can store small images fairly easily as base64 strings that can be served up in to the [B]src[/B] element of the [B]<img[/B] tag directly.

However, the practice is discouraged because it impacts on the database servers performance. Although the image would be data and a string, it would still be significantly longer to pull records, you would need to store very short strings and that means limiting file size.

Alter the membership table and add a field to the table for a very long string... this field, whatever name you call it, img_data for example, would either contain a URL or a Base64 String, either way, as long as the data is going to end up being written to an HTML[B] <img src=" ... " [/B]tag, then it doesn't matter because the result would be an image.

Then you would need to read the uploading images sticky in the sticky post at the top of the forum on image uploading.

You would need to decide on if you want to have images auto resized, giving the user the option to crop and size their image as they want it seen. Then save with best rate of compression, convert to a base64 String from a file then update a field in a table with the data of choice.

Then update the members table.
×

Success!

Help @anand_r spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...