开发者

Different users with profilepictures (as on facebook)

开发者 https://www.devze.com 2023-02-21 13:35 出处:网络
Hey! I want to create a site which reminds me of f开发者_C百科acebook for my school. I am fresh in this subject and I appreciate help!

Hey! I want to create a site which reminds me of f开发者_C百科acebook for my school. I am fresh in this subject and I appreciate help! What I have a hard time figuring out is how the users on the site can have a own profile picture after they have uploaded it to the site. For now I have a simple php form which will allow users to upload their picture, and a database created in Query Browser. The database contains id (Primary Key) and titleurl. Correct me if I'm wrong, but I want to store the images outside the database (on the disk/a folder in site root), and use the url on the pictures, www.exapmle.com/profilpictreu/yourimage.jpg. My teacher recommends me using a loop, but he honestly don't remember how to do it...

Can anyone help me out with the SQL and the coding?

Thanks for your replies


You might, instead, consider using gravatar, which lets the picture management happen somewhere else and all you need is their email address to access their picture.


If you want to store the image data in database table itself, you'll be wanting a Blob field... You would also need to write some code that, taking the user id for a parameter, returned the data in a file.

Alternatively, you could store the images away from the database, and have the database merely contain user data, together with a path to the image file corresponding to that user...


create an upload form for them to upload their picture. Store the file (after validating it of course). The easiest naming possibility is to name it after the user's id (with file extension). That way you can find the picture with the user's id.

Multiple pictures would require a second table so you can store a reference of the images to users.

0

精彩评论

暂无评论...
验证码 换一张
取 消