not completed image after decoding it php Android












0















PHP:



<?php
require "conn.php";
$cid = "6";// $_POST["cid"];
$mysql_qry = "select image2 from cities where ID = '$cid'";
$result = mysqli_query($conn,$mysql_qry);
$row = mysqli_fetch_array($result);

header('Content-Type: image/png');
echo base64_decode($row["image2"]);
$conn->close();
?>


and this is the result



enter image description here



How to solve that? my photo is almost black!










share|improve this question

























  • What do you expect to happen?

    – Nico Haase
    Nov 22 '18 at 16:08






  • 1





    What column type/length is image2? Are you certain the whole image is being saved?

    – iainn
    Nov 22 '18 at 16:15











  • @NicoHaase The rest of the image. the black part was an image before decoding it :(

    – Eman Fateen
    Nov 22 '18 at 16:24






  • 1





    5000 characters for a base64 encoded image doesn't sound like very much

    – iainn
    Nov 22 '18 at 16:29






  • 1





    Only you can answer that. Base-64 encode your image, and see how long the string is before saving it to the database. Your column needs to be at least that size.

    – iainn
    Nov 22 '18 at 16:34
















0















PHP:



<?php
require "conn.php";
$cid = "6";// $_POST["cid"];
$mysql_qry = "select image2 from cities where ID = '$cid'";
$result = mysqli_query($conn,$mysql_qry);
$row = mysqli_fetch_array($result);

header('Content-Type: image/png');
echo base64_decode($row["image2"]);
$conn->close();
?>


and this is the result



enter image description here



How to solve that? my photo is almost black!










share|improve this question

























  • What do you expect to happen?

    – Nico Haase
    Nov 22 '18 at 16:08






  • 1





    What column type/length is image2? Are you certain the whole image is being saved?

    – iainn
    Nov 22 '18 at 16:15











  • @NicoHaase The rest of the image. the black part was an image before decoding it :(

    – Eman Fateen
    Nov 22 '18 at 16:24






  • 1





    5000 characters for a base64 encoded image doesn't sound like very much

    – iainn
    Nov 22 '18 at 16:29






  • 1





    Only you can answer that. Base-64 encode your image, and see how long the string is before saving it to the database. Your column needs to be at least that size.

    – iainn
    Nov 22 '18 at 16:34














0












0








0








PHP:



<?php
require "conn.php";
$cid = "6";// $_POST["cid"];
$mysql_qry = "select image2 from cities where ID = '$cid'";
$result = mysqli_query($conn,$mysql_qry);
$row = mysqli_fetch_array($result);

header('Content-Type: image/png');
echo base64_decode($row["image2"]);
$conn->close();
?>


and this is the result



enter image description here



How to solve that? my photo is almost black!










share|improve this question
















PHP:



<?php
require "conn.php";
$cid = "6";// $_POST["cid"];
$mysql_qry = "select image2 from cities where ID = '$cid'";
$result = mysqli_query($conn,$mysql_qry);
$row = mysqli_fetch_array($result);

header('Content-Type: image/png');
echo base64_decode($row["image2"]);
$conn->close();
?>


and this is the result



enter image description here



How to solve that? my photo is almost black!







php






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 31 '18 at 10:18









Cœur

17.9k9107147




17.9k9107147










asked Nov 22 '18 at 15:57









Eman FateenEman Fateen

146




146













  • What do you expect to happen?

    – Nico Haase
    Nov 22 '18 at 16:08






  • 1





    What column type/length is image2? Are you certain the whole image is being saved?

    – iainn
    Nov 22 '18 at 16:15











  • @NicoHaase The rest of the image. the black part was an image before decoding it :(

    – Eman Fateen
    Nov 22 '18 at 16:24






  • 1





    5000 characters for a base64 encoded image doesn't sound like very much

    – iainn
    Nov 22 '18 at 16:29






  • 1





    Only you can answer that. Base-64 encode your image, and see how long the string is before saving it to the database. Your column needs to be at least that size.

    – iainn
    Nov 22 '18 at 16:34



















  • What do you expect to happen?

    – Nico Haase
    Nov 22 '18 at 16:08






  • 1





    What column type/length is image2? Are you certain the whole image is being saved?

    – iainn
    Nov 22 '18 at 16:15











  • @NicoHaase The rest of the image. the black part was an image before decoding it :(

    – Eman Fateen
    Nov 22 '18 at 16:24






  • 1





    5000 characters for a base64 encoded image doesn't sound like very much

    – iainn
    Nov 22 '18 at 16:29






  • 1





    Only you can answer that. Base-64 encode your image, and see how long the string is before saving it to the database. Your column needs to be at least that size.

    – iainn
    Nov 22 '18 at 16:34

















What do you expect to happen?

– Nico Haase
Nov 22 '18 at 16:08





What do you expect to happen?

– Nico Haase
Nov 22 '18 at 16:08




1




1





What column type/length is image2? Are you certain the whole image is being saved?

– iainn
Nov 22 '18 at 16:15





What column type/length is image2? Are you certain the whole image is being saved?

– iainn
Nov 22 '18 at 16:15













@NicoHaase The rest of the image. the black part was an image before decoding it :(

– Eman Fateen
Nov 22 '18 at 16:24





@NicoHaase The rest of the image. the black part was an image before decoding it :(

– Eman Fateen
Nov 22 '18 at 16:24




1




1





5000 characters for a base64 encoded image doesn't sound like very much

– iainn
Nov 22 '18 at 16:29





5000 characters for a base64 encoded image doesn't sound like very much

– iainn
Nov 22 '18 at 16:29




1




1





Only you can answer that. Base-64 encode your image, and see how long the string is before saving it to the database. Your column needs to be at least that size.

– iainn
Nov 22 '18 at 16:34





Only you can answer that. Base-64 encode your image, and see how long the string is before saving it to the database. Your column needs to be at least that size.

– iainn
Nov 22 '18 at 16:34












1 Answer
1






active

oldest

votes


















0















  • As i can see you are collecting image source from the database table. You must check that weather your entire image source is saved properly after encoding it. So check the database Column Data Type in which you have stored it i doubt that its not saving the full image source hence further you are not able to get the full image.


Advice : Most probably Best Practice is that you should convert it to image and save it on disk and just save the IMAGE SOURCE PATH on your Database Table Column. And then fetch it to display when required.
Otherwise Your DB will exausted and will start taking time in retrieving the records. Also problem will start in DB Backup and migrations.



If you dont want to follow the advise then change your column type to Either Blob depending on your image size.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434580%2fnot-completed-image-after-decoding-it-php-android%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0















    • As i can see you are collecting image source from the database table. You must check that weather your entire image source is saved properly after encoding it. So check the database Column Data Type in which you have stored it i doubt that its not saving the full image source hence further you are not able to get the full image.


    Advice : Most probably Best Practice is that you should convert it to image and save it on disk and just save the IMAGE SOURCE PATH on your Database Table Column. And then fetch it to display when required.
    Otherwise Your DB will exausted and will start taking time in retrieving the records. Also problem will start in DB Backup and migrations.



    If you dont want to follow the advise then change your column type to Either Blob depending on your image size.






    share|improve this answer




























      0















      • As i can see you are collecting image source from the database table. You must check that weather your entire image source is saved properly after encoding it. So check the database Column Data Type in which you have stored it i doubt that its not saving the full image source hence further you are not able to get the full image.


      Advice : Most probably Best Practice is that you should convert it to image and save it on disk and just save the IMAGE SOURCE PATH on your Database Table Column. And then fetch it to display when required.
      Otherwise Your DB will exausted and will start taking time in retrieving the records. Also problem will start in DB Backup and migrations.



      If you dont want to follow the advise then change your column type to Either Blob depending on your image size.






      share|improve this answer


























        0












        0








        0








        • As i can see you are collecting image source from the database table. You must check that weather your entire image source is saved properly after encoding it. So check the database Column Data Type in which you have stored it i doubt that its not saving the full image source hence further you are not able to get the full image.


        Advice : Most probably Best Practice is that you should convert it to image and save it on disk and just save the IMAGE SOURCE PATH on your Database Table Column. And then fetch it to display when required.
        Otherwise Your DB will exausted and will start taking time in retrieving the records. Also problem will start in DB Backup and migrations.



        If you dont want to follow the advise then change your column type to Either Blob depending on your image size.






        share|improve this answer














        • As i can see you are collecting image source from the database table. You must check that weather your entire image source is saved properly after encoding it. So check the database Column Data Type in which you have stored it i doubt that its not saving the full image source hence further you are not able to get the full image.


        Advice : Most probably Best Practice is that you should convert it to image and save it on disk and just save the IMAGE SOURCE PATH on your Database Table Column. And then fetch it to display when required.
        Otherwise Your DB will exausted and will start taking time in retrieving the records. Also problem will start in DB Backup and migrations.



        If you dont want to follow the advise then change your column type to Either Blob depending on your image size.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 8 '18 at 7:12









        Patel NikhilPatel Nikhil

        1154




        1154






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53434580%2fnot-completed-image-after-decoding-it-php-android%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Costa Masnaga

            Fotorealismo

            Sidney Franklin