Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在phpMyAdmin数据库中保存图像,正在获取[BLOB-0 B]_Php_Mysql_Upload - Fatal编程技术网

无法在phpMyAdmin数据库中保存图像,正在获取[BLOB-0 B]

无法在phpMyAdmin数据库中保存图像,正在获取[BLOB-0 B],php,mysql,upload,Php,Mysql,Upload,我正在尝试上载图像并将其保存在我的sql数据库中。 我试着上传了几张图片,但每次我都得到[BLOB-0b]。 我在php.ini中检查了文件_uploads=On 这是我的代码: regklub.php <html> <head></head> <body> <form action="regklub.php" method="post" enctype="multipart/form-data"> Logo: <inpu

我正在尝试上载图像并将其保存在我的sql数据库中。 我试着上传了几张图片,但每次我都得到[BLOB-0b]。 我在php.ini中检查了文件_uploads=On

这是我的代码: regklub.php

<html>
<head></head>
<body>
<form action="regklub.php" method="post" enctype="multipart/form-data">
    Logo: <input type="file" name="logo"><input type="submit" name="Submit" value="Upload">
</form>
<?php
if(isset($_POST['submit']))
{
    define('DB_NAME', 'lala');
    define('DB_USER', 'root');
    define('DB_HOST', 'localhost');
    $link = mysql_connect(DB_HOST, DB_USER,);
    if (!$link) {
    die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if (!$db_selected) {
die('Can\'t use ' . DB_NAME . ': ' . mysql_error());
}

    $imageName = mysql_real_escape_string($_FILES["logo"]["name"]);
    $imageData = mysql_real_escape_string(file_get_contents($_FILES["logo"]["tmp_name"]));

    echo $imageData;


}
?>

</body>
 </html>
给你举个例子

一个例子

$erroimagem= "";
$extensoes['extensoes'] = array('jpg', 'png', 'jpeg', 'JPG', 'JPEG');
$imagem = addslashes(file_get_contents($_FILES['imagem']['tmp_name']));
$extensao = strtolower(end(explode('.', $_FILES['imagem']['name'])));

    if (array_search($extensao, $extensoes['extensoes']) === false) {
        $erroimagem = "Por favor, envie arquivos com as seguintes extensões: jpg, png";
    } elseif ($_FILES['imagem']['size'] > 1000000) {
        $erroimagem = "O arquivo enviado é muito grande, envie arquivos de até 2Mb.";
    }

    if(empty($erroimagem)) {

    $query = mysql_query ("INSERT INTO utilizadores(imagem) VALUES ('$imagem', now())") or die (mysql_error());

    }

phpMyAdmin不是数据库。代码中的任何内容都不会向任何数据库中插入任何内容,所示代码中的任何内容也不会处理文件上载。我们需要最小可行的示例代码。此外,您可能会认真考虑将图像存储在DB中。在大多数情况下,这是一个坏主意;部分代码不起作用?我没有像本教程5:25那样得到这些图片符号