PHP照片库
我正试图用php为一个班级项目建立一个社交网站,但我对如何建立照片库有点困惑。我感到困惑的是我应该如何存储图片以及用于存储图片的数据库结构。任何帮助都将不胜感激。有很多方法可以做到这一点,但我将在这里为您提供最直接的方法。目标是让您了解基本步骤PHP照片库,php,Php,我正试图用php为一个班级项目建立一个社交网站,但我对如何建立照片库有点困惑。我感到困惑的是我应该如何存储图片以及用于存储图片的数据库结构。任何帮助都将不胜感激。有很多方法可以做到这一点,但我将在这里为您提供最直接的方法。目标是让您了解基本步骤 1- You should create a folder called 'images' under your root folder. 2- You upload the file to this folder. This tutorial show
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="">
1-您应该在根文件夹下创建一个名为“images”的文件夹。
2-将文件上载到此文件夹。本教程向您展示了如何:
http://www.w3schools.com/php/php_file_upload.asp
注意:您需要以自己选择的名称保存文件。选择唯一名称时要小心,以避免覆盖文件夹中的其他文件。
3-在数据库端,您只需要在服务器上插入文件的路径或URL。
4-在您的视图中,您可以这样插入图像:
“alt=”“>
我希望你能明白。祝你好运