2015-04-03 46 views
-2

我正在嘗試在php中爲一個類項目構建一個社交網站,我對如何構建相冊感到困惑。我很困惑的地方是我應該如何存儲圖片和用於存儲圖片的數據庫結構。任何幫助將非常感激。PHP相冊

回答

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=""> 

我希望你明白了。祝你好運!!!