www.webdeveloper.com
Results 1 to 6 of 6

Thread: image file to binary file conversion

Hybrid View

  1. #1
    Join Date
    Dec 2011
    Location
    Madurai,India
    Posts
    6

    Question image file to binary file conversion

    Hello all,

    I am creating a form using html5 and javascript. I need to display user image and am using <input type=file> tag to browse the image file. Now I need to convert the image file to binary file to store it in the web database.

    Is there any method in javascript for binary conversion....Please help me to convert image file to binary file.

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,252
    It's as far i know, it's not possible with javascript (not made to work with client files - security reasons). No problem with PHP.
    PHP Code:
    <?php 
    function data_uri($file$mime){
      
    $contents file_get_contents($file);
      
    $base64   base64_encode($contents);
      return (
    'data:' $mime ';base64,' $base64);
    }   
    ?>
    ...
    <img src="<?php echo data_uri('myimage.gif','image/gif');?>" alt="Image" />
    ...

  3. #3
    Join Date
    Jan 2009
    Location
    Insanity
    Posts
    1,131
    Also, please don't double post http://www.webdeveloper.com/forum/sh...d.php?t=254056 if your first post does not get answered, bump it by rephrasing your question or providing some code for people to work on and don't forget to wrap code in forum tags.
    We all have baggage to carry in life, unfortunately for me I always get the trolley with the wonky wheel...
    Code:
    Youre = {
          STILL_not_getting_it:function(){
               alert("YOU, the original poster / thread starter NEED to POST the code and NOT a LINK.");
          },
          MissingThePoint:function(msg){
                alert("You're missing the point. " + msg);
          }
    }
    Youre.STILL_not_getting_it();

  4. #4
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    yes, it is possible. there is no security problem with doing so either...

    files and canvas both had base64 exports available.
    use a file reader or canvas api to extract the data.

    http://www.html5rocks.com/en/tutorials/file/dndfiles/

    http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

  5. #5
    Join Date
    Oct 2011
    Posts
    18
    I am creating a form by means of html5 and javascript. I require to exhibit client picture and am using <input type=file> tag to browse the image file. Now I require to change the image file to binary file to store it in the web database.

  6. #6
    Join Date
    Jun 2013
    Posts
    27
    I can recommend this asp.net image converter to you which I bought the license but you can test the evaluation version that is free. This image converter can render image to binary file with the sample api and code. I've written my own image converting program by calling the api, so, if it is necessary, contact me.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles