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

Ajax File Field problem

exoskeleton
100+
P: 104
Hi..to all expert...i have this situation .. i cant get the value of the file field in the other page..im using a simple javascript like this...
example:

// this is page1.php

Expand|Select|Wrap|Line Numbers
  1. <head>
  2.  
  3. function send() {
  4.  
  5. var ajaxRequest;
  6.  
  7. //javascript code over here.....
  8. //javascript code over here.....
  9. //javascript code over here.....
  10. //javascript code over here.....
  11.  
  12. var name=document.getElementById('name').value;
  13. var file=document.getElementById('file_pic').value;
  14.  
  15. var queryString = "?name=" + name + "&file_pic=" + file;
  16.  
  17. ajaxRequest.open("GET", "page2.php" + queryString, true);
  18. ajaxRequest.send(null); 
  19.  
  20. }
  21.  
  22. </head>
  23.  
  24. <body>
  25. <input type="text" name="name" />
  26. <input name="file_pic" type="file" id="file_pic">
  27. <input type="button" name="submit" value="submit" onClick="send()">
  28. </body>
  29.  
ok so much for the page1.php....the text name is ok..it work but the file field is my problem...let me show you guyz the page2.php

this is page2.php

[PHP]<?php
include('include/dbcon.inc');

$floor = trim($_GET['name']);
$file = $_FILES['file']);

move_uploaded_file($file['tmp_name'], "./uploaded_image/" .$file['name']);

?>

[/PHP]ok i will stop right here...this move_uploaded_file command wont work...it doesn't upload the image to upload_image folder but the text is ok..it is save in the database.. only the file is my problem..

text inputs can be pass like this, right? but i dont know i file field is capable in this kind of process..please help me sir...


please help me dear experts...
thank you for viewing...more power
Sep 19 '06 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Ajax can't upload files. You will need to use an iframe instead. You can use something like this.
May 13 '08 #2

Post your reply

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