How to upload file using ajax?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • haytham2008
    New Member
    • Jun 2008
    • 14

    #1

    How to upload file using ajax?

    hi every body

    can i upload file using ajax ??

    if yes how
    pleaze with code

    thank u in advance
  • rnd me
    Recognized Expert Contributor
    • Jun 2007
    • 427

    #2
    Code:
    function IO(U, V) { // A tiny ajax library. by DanDavis
        var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
        X.open(V ? 'PUT' : 'GET', U, !1);
        X.setRequestHeader('Content-Type', 'text/html')
        X.send(V ? V : '');
    return X.responseText;
    }
    
    
    //  +++++++  customize code below  ++++++++
    
    var fileName= "text1.txt";
    var data= "hello world";
    
    IO( fileName, data ); //save it
    
    alert( IO( fileName ));  //check the file


    make sure your page's folder is setup for write access.
    Thus, I wouldn't do this in public if i were you.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      And if it has to be public, use an iframe.

      Comment

      • haytham2008
        New Member
        • Jun 2008
        • 14

        #4
        rnd me
        acoder

        thank u very much
        i will try it and told u :)

        Comment

        Working...