<bdo id='DjB3a'></bdo><ul id='DjB3a'></ul>

    <small id='DjB3a'></small><noframes id='DjB3a'>

    <tfoot id='DjB3a'></tfoot>
  1. <legend id='DjB3a'><style id='DjB3a'><dir id='DjB3a'><q id='DjB3a'></q></dir></style></legend>

  2. <i id='DjB3a'><tr id='DjB3a'><dt id='DjB3a'><q id='DjB3a'><span id='DjB3a'><b id='DjB3a'><form id='DjB3a'><ins id='DjB3a'></ins><ul id='DjB3a'></ul><sub id='DjB3a'></sub></form><legend id='DjB3a'></legend><bdo id='DjB3a'><pre id='DjB3a'><center id='DjB3a'></center></pre></bdo></b><th id='DjB3a'></th></span></q></dt></tr></i><div id='DjB3a'><tfoot id='DjB3a'></tfoot><dl id='DjB3a'><fieldset id='DjB3a'></fieldset></dl></div>
    1. 将图像上传到数据库,PHP和Mysql后无法显示

      Can#39;t display image after uploading it to a data base, PHP and Mysql(将图像上传到数据库,PHP和Mysql后无法显示)

      <small id='BGCOs'></small><noframes id='BGCOs'>

          <tfoot id='BGCOs'></tfoot>
          <i id='BGCOs'><tr id='BGCOs'><dt id='BGCOs'><q id='BGCOs'><span id='BGCOs'><b id='BGCOs'><form id='BGCOs'><ins id='BGCOs'></ins><ul id='BGCOs'></ul><sub id='BGCOs'></sub></form><legend id='BGCOs'></legend><bdo id='BGCOs'><pre id='BGCOs'><center id='BGCOs'></center></pre></bdo></b><th id='BGCOs'></th></span></q></dt></tr></i><div id='BGCOs'><tfoot id='BGCOs'></tfoot><dl id='BGCOs'><fieldset id='BGCOs'></fieldset></dl></div>
                <tbody id='BGCOs'></tbody>
                <bdo id='BGCOs'></bdo><ul id='BGCOs'></ul>
                <legend id='BGCOs'><style id='BGCOs'><dir id='BGCOs'><q id='BGCOs'></q></dir></style></legend>
              • 本文介绍了将图像上传到数据库,PHP和Mysql后无法显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我需要为客户制作一个网页,以将图像上传到数据库并显示它们.

                I need to do a web page for a client to upload images to a data base and display them.

                我可以将图像上传到数据库中,但我无法显示它们,但我不知道为什么

                I am achieve to upload the images into a database, but I'm having trouble displaying them, but I can't work out why

                这是我的代码:

                <!DOCTYPE html>
                    <head>
                    <body>
                
                    <form action="form.php" method="post" enctype="multipart/form-data">
                        File:
                        <input type="file" name="image" /> <input type="submit" value="Upload" />
                    </form>
                
                    <?php 
                        mysql_connect("localhost", "root", "") or die(mysql_error());
                        mysql_select_db("test" ) or die(mysql_error());
                
                        $file = $_FILES['image'] ['tmp_name'];
                
                        if (!isset($file)) {
                            echo "<br>Please select an image.";
                        }
                        else {
                            $image = addslashes(file_get_contents($_FILES['image'] ['tmp_name']));
                            $imageName = addslashes($_FILES['image']['name']);
                            $imageSize = getimagesize($_FILES['image']['tmp_name']);
                
                            if ($imageSize == FALSE)
                                echo "<br><br>Thats not an image. <br><br>";
                
                
                            else{
                                if (!$insert = mysql_query("INSERT INTO imgup VALUES ('','$imageName','$image')"))
                                    echo "Problem uploading the image.";
                                else{
                                    $lastId = mysql_insert_id();
                                    echo "Article uploaded.<p /> Your image:<p /> <img src=get.php?id=$lastId>";
                                }
                            }
                        }
                
                        ?>
                
                    </body>
                </html>
                

                这是我将图像 blob 转换为图像的文件:

                This is my file who turn the image blob into an image:

                <?php 
                    mysql_connect("localhost", "root", "") or die(mysql_error());
                    mysql_select_db("test" ) or die(mysql_error());
                
                        $id = addslashes($_REQUEST['id']);
                
                
                        $image = mysql_query("SELECT * FROM blog WHERE id=$id");
                        $image = mysql_fetch_assoc($image);
                        $image = $image['image'];
                
                        header("Content-type: image/jpeg");
                
                        echo $image;
                
                ?>
                

                最后图像不显示,这就是我得到的:http://goo.gl/gi1Uuc

                And at the end the image does not display and this is what i get: http://goo.gl/gi1Uuc

                如果我去检查我的数据库,图像已经成功上传......

                And if i go and check my database, the image has ben successfully uploaded...

                推荐答案

                根据文件使用内联base64编码.这是通过以下方式完成的:

                Depending on the file use inline base64 encoding. This is done with:

                echo '<img src="data:image/jpeg;base64,'.base64_encode( $image ).'"/>';
                

                字体:base64_encode

                T大写(Type),因为在IE中会报错.尝试使用函数 file_get_contents 进行打印.

                Put the T upperCase (Type), because can giving error in IE. Try printing with the function file_get_contents.

                header('Content-Type: image/jpeg');
                echo readfile($image);
                

                这篇关于将图像上传到数据库,PHP和Mysql后无法显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                <i id='lNV53'><tr id='lNV53'><dt id='lNV53'><q id='lNV53'><span id='lNV53'><b id='lNV53'><form id='lNV53'><ins id='lNV53'></ins><ul id='lNV53'></ul><sub id='lNV53'></sub></form><legend id='lNV53'></legend><bdo id='lNV53'><pre id='lNV53'><center id='lNV53'></center></pre></bdo></b><th id='lNV53'></th></span></q></dt></tr></i><div id='lNV53'><tfoot id='lNV53'></tfoot><dl id='lNV53'><fieldset id='lNV53'></fieldset></dl></div>
                    <tbody id='lNV53'></tbody>

                  • <tfoot id='lNV53'></tfoot>
                  • <legend id='lNV53'><style id='lNV53'><dir id='lNV53'><q id='lNV53'></q></dir></style></legend>

                    <small id='lNV53'></small><noframes id='lNV53'>

                          <bdo id='lNV53'></bdo><ul id='lNV53'></ul>