By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,688 Members | 1,715 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,688 IT Pros & Developers. It's quick & easy.

How to upload file using ajax?

P: 14
hi every body

can i upload file using ajax ??

if yes how
pleaze with code

thank u in advance
Jun 11 '08 #1
Share this Question
Share on Google+
3 Replies


rnd me
Expert 100+
P: 427
Expand|Select|Wrap|Line Numbers
  1.  
  2. function IO(U, V) { // A tiny ajax library. by DanDavis
  3.     var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
  4.     X.open(V ? 'PUT' : 'GET', U, !1);
  5.     X.setRequestHeader('Content-Type', 'text/html')
  6.     X.send(V ? V : '');
  7. return X.responseText;
  8. }
  9.  
  10.  
  11. //  +++++++  customize code below  ++++++++
  12.  
  13. var fileName= "text1.txt";
  14. var data= "hello world";
  15.  
  16. IO( fileName, data ); //save it
  17.  
  18. alert( IO( fileName ));  //check the file
  19.  
  20.  


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

acoder
Expert Mod 15k+
P: 16,027
And if it has to be public, use an iframe.
Jun 12 '08 #3

P: 14
rnd me
acoder

thank u very much
i will try it and told u :)
Jun 13 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.