需要帮助:我正在使用一个简单的 PHP 代码将照片上传到远程数据库。但是.. 每次,一张照片的两个副本都保存在数据库中。谁能告诉我我做错了什么?PHP代码:
<?PHP
$uploadDir = 'image_folder/';
$uploadDir = 'image_folder/';
if(isset($_POST['Submit'])) //info saving in the variables
{
$fileName = $_FILES['Photo']['name'];
$tmpName = $_FILES['Photo']['tmp_name'];
$fileSize = $_FILES['Photo']['size'];
$fileType = $_FILES['Photo']['type'];
$filePath = $uploadDir . $fileName;
$result = move_uploaded_file($tmpName, $filePath); //moving the photo in the destination
if (!$result) {
echo "Error uploading file";
exit;
}
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}
echo "".$filePath."";
$query = "INSERT INTO picture (image) VALUES ('$filePath')";
if (mysql_query($query))
{echo "Inserted";}
mysql_query($query) or die('Error loading file!');
}?>