Re: need to insert values in database table

  •  03-21-2011, 2:16 PM

    Re: need to insert values in database table

    Dear sheik1412,
     
    Please refer to the following two files, if you save these two files, you will can run ajax-multiplefiles.php directly, this example demonstrates how to pass parameter between php uploader and its handler:
     
    Ajax-multiplefiles.php:

    <?php require_once "phpuploader/include_phpuploader.php" ?>
    <?php session_start(); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
          <title>
                Ajax - Multiple files upload
          </title>
          <link href="demo.css" rel="stylesheet" type="text/css" />
          <script type="text/javascript">
                var handlerurl='ajax-multiplefiles-handler.php?idget=503'
          </script>
          <script type="text/javascript">
          function CuteWebUI_AjaxUploader_OnPostback()
          {
                var uploader = document.getElementById("myuploader");
                var guidlist = uploader.value;

                //Send Request
                var xh;
                if (window.XMLHttpRequest)
                      xh = new window.XMLHttpRequest();
                else
                      xh = new ActiveXObject("Microsoft.XMLHTTP");
               
                xh.open("POST", handlerurl, false, null, null);
                xh.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
                var deleteid=505;
                xh.send("guidlist=" + guidlist+ "&idpost=" + deleteid);

                //call uploader to clear the client state
                uploader.reset();

                if (xh.status != 200)
                {
                      alert("http error " + xh.status);
                      setTimeout(function() { document.write(xh.responseText); }, 10);
                      return;
                }

                var filelist = document.getElementById("filelist");

                var list = eval(xh.responseText); //get JSON objects
                //Process Result:
                for (var i = 0; i < list.length; i++)
                {
                      var item = list[i];
                      var msg = "Processed: " + list[i].FileName;
                      var li = document.createElement("li");
                      li.innerHTML = msg;
                      filelist.appendChild(li);
                }
          }
          </script>

    </head>
    <body>
          <div class="demo">                       
            <h2>Selecting multiple files for upload</h2>
                <p>PHP File Uploader allows you to select multiple files and upload multiple files at once.</p>
                   
                      <?php
                            $uploader=new PhpUploader();
                            $uploader->MaxSizeKB=10240;
                            $uploader->Name="myuploader";
                            $uploader->MultipleFilesUpload=true;
                            $uploader->InsertText="Select multiple files (Max 10M)";
                            $uploader->AllowedFileExtensions="*.jpg,*.png,*.gif,*.bmp,*.txt,*.zip,*.rar";    
                            $uploader->Render();
                      ?>
                                 
                      <ol id="filelist">
                      </ol>      
          </div>
    </body>
    </html>

    ajax-multiples-handler.php:

    <?php require_once "phpuploader/include_phpuploader.php" ?>
    <?php

    $uploader=new PhpUploader();

    $guidarray=explode("/",$_POST["guidlist"]);

    //OUTPUT JSON

    echo("[");
    $count=0;
    foreach($guidarray as $fileguid)
    {
          $mvcfile=$uploader->GetUploadedFile($fileguid);
          if(!$mvcfile)
                continue;
         
          //process the file here , move to some where
          //rename(...)    
         
          if($count>0)
                echo(",");
          echo("{");
          echo("FileGuid:'");echo($mvcfile->FileGuid);echo("'");
          echo(",");
          echo("FileSize:'");echo($mvcfile->FileSize);echo("'");
          echo(",");
          echo("FileName:'");echo($mvcfile->FileName);echo("'");
          echo("}");
          $count++;
    }
    echo("]");
    ?>
     
    Thank you for asking
View Complete Thread