Ajax File Field problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • exoskeleton
    New Member
    • Sep 2006
    • 104

    Ajax File Field problem

    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

    Code:
    <head>
    
    function send() {
    
    var ajaxRequest;
    
    //javascript code over here.....
    //javascript code over here.....
    //javascript code over here.....
    //javascript code over here.....
    
    var name=document.getElementById('name').value;
    var file=document.getElementById('file_pic').value;
    
    var queryString = "?name=" + name + "&file_pic=" + file;
    
    ajaxRequest.open("GET", "page2.php" + queryString, true);
    ajaxRequest.send(null); 
    
    }
    
    </head>
    
    <body>
    <input type="text" name="name" />
    <input name="file_pic" type="file" id="file_pic">
    <input type="button" name="submit" value="submit" onClick="send()">
    </body>
    ok so much for the page1.php....th e 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('includ e/dbcon.inc');

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

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

    ?>

    [/PHP]ok i will stop right here...this move_uploaded_f ile 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
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Ajax can't upload files. You will need to use an iframe instead. You can use something like this.

    Comment

    Working...