English 中文(简体)
PHP图像上传方法
原标题:PHP image upload method

我正在开发一个PHP网站,我很难选择存储上传文件的最佳方法。

目前,我正在考虑将图像作为BLOB存储在MySQL数据库中,但也有人告诉我,存储图像的文件名就足够了。

最佳回答

两者都有优点和缺点,就我个人而言,我喜欢将图像存储在数据库之外,并在数据库中使用varchar引用文件。

如果您想将它们存储为blob,那么本文是一篇非常平衡的文章。

http://www.phpro.org/tutorials/Storing-Images-in-MySQL-with-PHP.html

问题回答

在我看来,只在数据库中存储文件名是一种快速而丰富的技术。您应该将文件保存在任何其他目录中。当你必须检索上传的文件时,你只需要将其与存储的名称进行比较。如果您要存储多种类型的文件,那么将它们存储在不同的目录中总是一种很好的技术。因此,在我看来,将文件名存储在数据库和其他地方是一种快速而好的技术





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签