2015-04-03 6 views
-2

Я пытаюсь построить сайт социальной сети для проекта класса в php, и я немного запутался в том, как построить фотогалерею. Там, где я запутался, я должен хранить фотографии и структуру базы данных для хранения изображений. Любая помощь приветствуется.PHP photo gallery

ответ

0

Есть много способов приблизиться к этому, но я дам вам здесь самый простой способ. Цель состоит в том, чтобы вы могли понять основные этапы.

1- You should create a folder called 'images' under your root folder. 
2- You upload the file to this folder. This tutorial shows you how : 
    http://www.w3schools.com/php/php_file_upload.asp 
    Note: you will want to save the file under a name of your choice. Be careful in chosing a unique name to avoid overwriting other files in the folder. 
3- On the database side, you will just need to insert the PATH or URL of the file on your server. 
4- In your view, you would insert the image this way : 
    <img src="<?php echo $image_path; ?>" alt=""> 

Надеюсь, у вас есть идея. Удачи!!!