www.webdeveloper.com
Results 1 to 14 of 14

Thread: xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')

  1. #1
    Join Date
    Oct 2004
    Posts
    566

    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')

    For some reason a + gets to be replaced by a space -> <- when sending a requset like this
    PHP Code:
    data='ABGHJKIJH/SDSSDSD+'
    xmlHttp=new XMLHttpRequest()
    xmlHttp.open('POST',cgi,true)
    xmlHttp.setRequestHeader('Content-Type''application/x-www-form-urlencoded')
    xmlHttp.send('v='+encodeURIComponent(data)) 
    explenation please why my + is getting replaced ? Also seems like xmlHttp.setRequestHeader('Content-Type', 'text/plain') doesnt work at all ?
    Last edited by gert cuykens; 10-10-2006 at 09:21 PM.

  2. #2
    Join Date
    Oct 2004
    Posts
    566
    seems php has two different urldecoders

    http://be.php.net/manual/en/function.rawurldecode.php

  3. #3
    Join Date
    Oct 2004
    Posts
    566
    ps how do i solve the space folowed by space that gets replaced by once space instead of two?

  4. #4
    Join Date
    Oct 2006
    Posts
    150
    Hmm, can you please show me the server-side code you're using? (Relevant parts)

  5. #5
    Join Date
    Oct 2004
    Posts
    566
    never mind i found a solution and convert it into base64 first folowed by urlencoding

    PS why does firefox corrupt my blob's when i display them in a textarea ? The null character (\0) gets destroyed ?

  6. #6
    Join Date
    Oct 2006
    Posts
    150
    Why in the world do you want to store something containing a \0 in a textarea??

  7. #7
    Join Date
    Oct 2004
    Posts
    566
    lol i dont know, JPEG files are full of \0 characters. And when you delete them you get a different picture. So why do they get deleted automaticly in a textarea and how can i tell firefox not to do that?

  8. #8
    Join Date
    Oct 2006
    Posts
    150
    A jpeg file in a textarea? Sounds hilarious to me. Maybe you could keep it base64-encoded until you recieve it on the serverside again? You could also try using using the htmlentities function and print the jpeg to a hidden form field:
    Code:
    <input type="hidden" name="foobar" value="<?PHP echo htmlentities(jpegdata); ?>" />

  9. #9
    Join Date
    Oct 2006
    Posts
    150
    Or, shall I add, try to fins a solution that doesn't involve sending the image to the user.

  10. #10
    Join Date
    Oct 2004
    Posts
    566
    i have two choises, the server puts the image in session memory or it gets stored in a client text area ?

    Witch one would you pic ?

  11. #11
    Join Date
    Oct 2006
    Posts
    150
    choices, which, pick
    Where do you get the image data from? A file? If so, why not simply pass the file name or something?

  12. #12
    Join Date
    Oct 2004
    Posts
    566
    a mysql db. You know phpmyadmin? I think i can do much better. I will show you when its finished, right now i am trying to figure out the best way to handle blob's
    Last edited by gert cuykens; 10-11-2006 at 03:59 PM.

  13. #13
    Join Date
    Mar 2005
    Posts
    250
    If I'm understanding correctly what you're trying to do here, I think the key will be a PHP file that queries for your blob data, echoes it out, and then sets its own MIME type to image/jpeg (or whatever). Then all you need on your page is an <img src="image.php" />, and your JavaScript can change the src to pass whatever information you need for your query:

    image.php?whatever=whatever
    Last edited by tarsus; 10-11-2006 at 05:54 PM.

  14. #14
    Join Date
    Oct 2004
    Posts
    566
    Picture a database with one column that contains blob information. Now think of a sql statemant that updates one of the blob's (in this case jpeg). Believe me you will have some freaking looking sql statemant with a lot off weird characters. I am trying to visualise this sql statemant trough a textarea with as little overhead as possible currently phpmyadmin visualise it with a hex number witch is not a good idea for big files.

    Again wait until my version is finished and have my gpl license stampelt on it, and it will all be clear

Thread Information

Users Browsing this Thread

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

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