Can't display image after uploading it to a data base, PHP and Mysql

后端 未结 4 1731
耶瑟儿~
耶瑟儿~ 2020-12-22 13:05

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 di

相关标签:
4条回答
  • 2020-12-22 13:22

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

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

    Font: base64_encode

    OR

    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);
    
    0 讨论(0)
  • 2020-12-22 13:39

    Escaping an image file with addslashes will probably corrupt it, the imagesize test should be sufficient

    0 讨论(0)
  • 2020-12-22 13:40

    I wouldn't store any image in a database. You should save it as file, and store the file's name in the database. You can then configure which directory an image gets served from without worrying about the full path to the image, or storing binary data in your db (yuck).

    0 讨论(0)
  • 2020-12-22 13:46

    Try changing:

    $image = mysql_query("SELECT * FROM blog WHERE id=$id");
    

    to:

    $image = mysql_query("SELECT * FROM blog WHERE id = '$id'");
    
    0 讨论(0)
提交回复
热议问题