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 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    img src=blob: how to convert to file?

    Hello,

    I've a generated image:

    Code:
    <img id="imgcaptmobile" width="487" src="blob:http%3A//www.monsite.com/4afa5259-b041-4a0a-9f8b-fa9c6192eb87">
    I'd like to upload it as a file (like .jpg) with ajax. How to convert it please?
    Thanks

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,316
    Thanks
    23
    Thanked 613 Times in 612 Posts
    Don't try to send an image. Send a link to where it exists in your files or where to retrieve it from your database.
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #3
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In my case I click on a button, then choose a file on my PC. Then it is displayed like blob:http://xxxxxxx/ddsqdsqdsqd-sqdsqdsq-dsqddq

    I don't know how to send it, image or url...

  • #4
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,375
    Thanks
    11
    Thanked 592 Times in 572 Posts
    i would probably just use the dataURL version and un-base64 the string to the right of the "," on the server to get the raw binary data.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.6, IE11:9.1, IE9:3.1, IE10:3.0, FF:17.2, CH:46, SF:11.4, NON-MOUSE:38%

  • #5
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, but I don't know how to convert (see subject of the thread ;-) )...

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,014
    Thanks
    79
    Thanked 4,435 Times in 4,400 Posts
    I think the point is that the generated image is *NOT* from his own site.

    He is trying to grab content from another site and save the image on his own site.

    Recif: True?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Assuming that the OP has the owner's permission to copy the image (as is necessary in order to be allowed to use it) why not simply ask for it in the desired format.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,014
    Thanks
    79
    Thanked 4,435 Times in 4,400 Posts
    Ahh, you take all the fun out of it by expecting people to only do legal things.

    Sure your name isn't Flegall ??

    <grin/>

    Yes, that's exactly what I was implying: He's trying to improperly "rip" content.

    But we shall see.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #9
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,375
    Thanks
    11
    Thanked 592 Times in 572 Posts
    Quote Originally Posted by Old Pedant View Post
    Yes, that's exactly what I was implying: He's trying to improperly "rip" content.
    i highly doubt that, SOP would prevent any outside image data from making it to the blob url shown by OP, but more-over he said "I click on a button, then choose a file on my PC". don't be accusatory. remember the lessons of Sodom and Gomorrah and try to be hospitable to strangers...

    OP: you don't need to obtain the blob window.URL to upload, the blob object itself is fine.
    You can either simply xhrt.send(blob), use the FormData virtual file builder and upload that, or use FileReader.readAsDataURL(blob) to grab the base64 data i alluded to before. each has a different server routine for catching the data, but it sounds like you havn't gotten to the server yet. at any rate, you have many options before you.

    you might want to check out https://developer.mozilla.org/en-US/...ploading_files
    Last edited by rnd me; 06-27-2013 at 08:19 AM.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/9/03) IE7:0.1, IE8:4.6, IE11:9.1, IE9:3.1, IE10:3.0, FF:17.2, CH:46, SF:11.4, NON-MOUSE:38%


  •  

    Posting Permissions

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