Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New to the CF scene
    Join Date
    Apr 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    image retriving problem

    i am trying retrive image from oracle blob. i have used fopen,fwrite and fclose for this. the problem is that only half image is getting retrived. dose any on has solution for this ???

  • #2
    Regular Coder
    Join Date
    Sep 2011
    Posts
    408
    Thanks
    18
    Thanked 26 Times in 26 Posts
    Here's the function you need:
    PHP Code:
    /*
    * @credit Dubz
    *
    * Opens and saves an image from a website or local location
    *
    * @param $inPath Location to get image
    * @param $directory Location to save image
    * @return Returns a boolean of if the image was saved
    */
    function save_image($inPath$directory '')
    {
        
    //Download images from remote server
        
    $file explode('/'$inPath);
        
    $file array_pop($file);
        if(
    substr($directory, -1) != '/' || empty($directory))
            
    $directory .= '/';
        if(!
    is_dir($directory))
            
    mkdir($directory);
        
    $outPath $directory.$file;
        
    $in = @fopen($inPath"rb");
        if(
    $in)
        {
            
    $out fopen($outPath"wb");
            while (
    $chunk fread($in8192))
            {
                
    fwrite($out$chunk8192);
            }
            
    fclose($in);
            
    fclose($out);
            return 
    true;
        }
        else
            return 
    false;

    It would be called with something like this:
    PHP Code:
    //This will save to a path relative to the php script (you can have it move up directories with '../')
    save_image('http://www.codingforums.com/img/logo.gif''images/codingforums/'); 
    If you want to see any other functions I bundled together, check out the Basic PHP Functions post I made in the snippets section.
    Last edited by Dubz; 04-06-2013 at 06:13 PM.

  • #3
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,299
    Thanks
    57
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    Dubz your reply was not helpful in the slightest.

    Re-read the op again. The op is trying tro retrieve an image from an oracle database that is stored in a blob field. They are only getting half of the image out of it.

    How is supplying code that downloads a file via http and saves it to disk going to solve this? - Will it get the image from a blob field? No. Will it retrieve the whole image instead of half from the blob field? No. Does it even connect to the oracle database? No.

    ashishghate: You need to show some code really to show what you are doing and how. I have no experience using oracle databases but I'm sure one of our superior coders / mods will be able to help you.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #4
    Regular Coder
    Join Date
    Sep 2011
    Posts
    408
    Thanks
    18
    Thanked 26 Times in 26 Posts
    Quote Originally Posted by tangoforce View Post
    Dubz your reply was not helpful in the slightest.

    Re-read the op again. The op is trying tro retrieve an image from an oracle database that is stored in a blob field. They are only getting half of the image out of it.

    How is supplying code that downloads a file via http and saves it to disk going to solve this? - Will it get the image from a blob field? No. Will it retrieve the whole image instead of half from the blob field? No. Does it even connect to the oracle database? No.
    To me that just sounds like someone needs to take a chill pill. I never heard of an oracle blob and figured it was a website or type of website. You can't assume everyone knows everything and bash on them when they don't, it's not my fault I haven't learned every possible thing on the internet.

  • #5
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,299
    Thanks
    57
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    Quote Originally Posted by Dubz View Post
    To me that just sounds like someone needs to take a chill pill. I never heard of an oracle blob and figured it was a website or type of website. You can't assume everyone knows everything and bash on them when they don't, it's not my fault I haven't learned every possible thing on the internet.
    So if you don't know then you're not suited to offering advice. Leave it to the experts like Fou and Inigoesdr.

    Your reply was more aimed at getting your code snippet more publicity and attention. You claim I need to take a chill pill yet you're the one resorting to these unhelpful tactics to get attention for your code
    Last edited by tangoforce; 04-07-2013 at 11:11 PM.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    :facepalm:
    For the OP, define "half"? I would figure that if you only had half of the image data that it would likely not render at all (although I guess something like a bitmap probably could). What's the datatype declaration for the blob; is it sufficiently large enough to store the file size (if you didn't override the size, than the default is 2GB which should be more than enough to store any image)?
    Also, you don't really need to use file writing techniques unless you actually need to store the file. But if you need that anyway, I'm curious as to why you have the database in between in the first place. Despite the advantage of storing binary file data in a db so it is easy to move, it is *much* faster to use a filesystem access instead.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #7
    Banned
    Join Date
    Mar 2013
    Posts
    139
    Thanks
    0
    Thanked 9 Times in 9 Posts
    Quote Originally Posted by Dubz View Post
    I never heard of an oracle blob and figured it was a website or type of website.
    In the future, if you're not sure what something is, find out what it is before replying otherwise, apart from making yourself look silly your reply won't be of any help to the op and will most probably only confuse them because they might mistakenly assume you know what you are talking about.

    Does the word "Google" mean anything to you

    If not, then

    www.lmgtfy.com/?q=oracle+blob

  • #8
    Regular Coder
    Join Date
    Sep 2011
    Posts
    408
    Thanks
    18
    Thanked 26 Times in 26 Posts
    Quote Originally Posted by tangoforce View Post
    So if you don't know then you're not suited to offering advice.
    I am sorry master of everything in the world, as if you've never made a mistake in your life.

    As for Googling it, I was busy and have been trying to help out on the forums instead of always asking for help. I mean sure it's for getting help but always asking makes me feel needy, I'd like to help out too. It's not exactly my fault for not spending my entire time of my day researching every possible thing that's out there. I've taught myself most of what I know so far through the aid of youtube, examples, and some questions along the way I posted here. I never took any sort of class on this language and I've taught myself while living my life. I don't try to impress other people on here, I try to assist them when I can and in trade for assistance when I need it. Instead of basing on people when they make a mistake, try correcting them politely and be a good teacher instead of a dick, you'll be given more respect that way.

  • #9
    Junsee
    Guest
    Yeah I would start with the simple stuff first.
    print the blob to screen and see how much you are getting.
    compare it to the database entry.

    and give us some code so we can see what you are doing!

  • #10
    Banned
    Join Date
    Mar 2013
    Posts
    139
    Thanks
    0
    Thanked 9 Times in 9 Posts
    Quote Originally Posted by Dubz View Post
    As for Googling it, I was busy and have been trying to help out on the forums instead of always asking for help......It's not exactly my fault for not spending my entire time of my day researching every possible thing that's out there.
    Of course no-one knows everything about everything. But surely when someone asks for help in a forum it is not unreasonable for them to expect that any replies would be from people who what they are talking about.

    In a way helping someone in a forum is a bit like being a teacher in a classroom. I doubt real teachers would be able to use the same lame excuse you tried to use for posting jibberish relative to the op's request.

    It would have taken you no more than 2 minutes to google "oracle blob" and you would have realised immediately it is not a website or type of website as you incorrectly assumed. Given that, I agree with tangoforce and your post was more about you promoting some basic code of your own rather than trying to help the op.

  • #11
    Regular Coder
    Join Date
    Sep 2011
    Posts
    408
    Thanks
    18
    Thanked 26 Times in 26 Posts
    Quote Originally Posted by knightCoder View Post
    In a way helping someone in a forum is a bit like being a teacher in a classroom. I doubt real teachers would be able to use the same lame excuse you tried to use for posting jibberish relative to the op's request.
    I agree with partially, this is like teaching in a classroom, but some teachers make mistakes and correct them. You can ask your science teacher questions about science, but he isn't going to know all of the answers for every subject in science.

    Quote Originally Posted by knightCoder View Post
    Given that, I agree with tangoforce and your post was more about you promoting some basic code of your own rather than trying to help the op.
    With the fact that me "promoting" or "advertising" my script gives me no advantage whatsoever makes that useless. I posted it to let people know it's there to help them be assisted because a lot of the functions on t are very useful and could help out with scripts. I've seen posts before asking for ways to do things that they would be nice, so I figured I would start pointing it out a little more, especially since some people don't even know that section exists.

    The only reason I have that file posted is because the functions in them are very resourceful and have helped me with many projects (some more than others).

  • #12
    Banned
    Join Date
    Mar 2013
    Posts
    139
    Thanks
    0
    Thanked 9 Times in 9 Posts
    Quote Originally Posted by Dubz View Post
    You can ask your science teacher questions about science, but he isn't going to know all of the answers for every subject in science.
    yes that's true but he's also then going to say "Hey Johnny, that's a good question but I don't know the answer and I'll try to find the answer for you by tomorrow"

    He's not going to make an assumption and risk getting it horribly wrong, as in your case, and risk misleading the student or worse still losing the confidence of the student.

  • #13
    Regular Coder
    Join Date
    Sep 2011
    Posts
    408
    Thanks
    18
    Thanked 26 Times in 26 Posts
    Quote Originally Posted by knightCoder View Post
    "Hey Johnny, that's a good question but I don't know the answer and I'll try to find the answer for you by tomorrow"
    The only time I hear a teacher say that is when they know what you mean and know they don't know anything about it. You could ask him a question and he could think you mean something else, that happens a lot, especially in my technology classes.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •