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
    Master Coder
    Join Date
    Jan 2011
    Location
    Washington
    Posts
    5,481
    Thanks
    26
    Thanked 753 Times in 751 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.

    Because I love FLEXBOX and tired of waiting: http://davidwalsh.name/goodbye-vendor-prefixes

  • #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,610
    Thanks
    11
    Thanked 619 Times in 599 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.
    Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com

  • #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
    29,543
    Thanks
    89
    Thanked 4,934 Times in 4,895 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?
    Be yourself. No one else is as qualified.

  • #7
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    7,186
    Thanks
    0
    Thanked 718 Times in 707 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
    29,543
    Thanks
    89
    Thanked 4,934 Times in 4,895 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.
    Be yourself. No one else is as qualified.

  • #9
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,610
    Thanks
    11
    Thanked 619 Times in 599 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.
    Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com


  •  

    Posting Permissions

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