Re: Can't Find the file

  •  08-20-2009, 10:46 AM

    Re: Can't Find the file

    I have finally figured the answer: both the Ajax control and the code to move the uploaded file reside in the same file!!!!
     
    Why couldn't you just say so? 
    1. <?php require_once "phpuploader/include_phpuploader.php" ?>
    2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    3. <html xmlns="http://www.w3.org/1999/xhtml">
    4. <head>
    5. <title>
    6. Form - Multiple files upload
    7. </title>
    8. <link href="demo.css" rel="stylesheet" type="text/css" />
    9. <script type="text/javascript">
    10. function CuteWebUI_AjaxUploader_OnPostback() {
    11. //submit the form after the file have been uploaded:
    12. document.forms[0].submit();
    13. }
    14. </script>
    15. </head>
    16. <body>
    17. <div class="demo">                        
    18.         <h2>Selecting multiple files for upload</h2>
    19. <p>PHP File Uploader allows you to select multiple files and upload multiple files at once.</p>
    20. <!-- do not need enctype="multipart/form-data" -->
    21. <form id="form1" method="POST">
    22. <?php

    23. $uploader=new PhpUploader();
    24. $uploader->MaxSizeKB=10240;
    25. $uploader->MultipleFilesUpload=true;
    26. $uploader->Name="myuploader";
    27. $uploader->InsertText="Select multiple files (Max 10M)";
    28. $uploader->Render();

    29. ?>
    30. </form>
    31. <br/><br/>
    32. <?php
    33. $fileguidlist=@$_POST["myuploader"];
    34. if($fileguidlist)
    35. {

    36.                         $docRoot = $_SERVER['DOCUMENT_ROOT'];//used for reading files
                              $userName 
                              $dir = "$docRoot/$userName/"; 
       
    37. $guidlist=split("/",$fileguidlist);
    38. echo("<div style='font-family:Fixedsys;'>");
    39. echo(count($guidlist));
    40. echo(" files Uploaded:");
    41. echo("</div>");
    42. echo("<hr/>");
    43. foreach($guidlist as $fileguid)
    44. {
    45. $mvcfile=$uploader->GetUploadedFile($fileguid);
    46. if($mvcfile)
    47. {
    48. echo("<div style='font-family:Fixedsys;border-bottom:dashed 1px gray;padding:6px;'>");
    49. echo("FileName : ");
    50. echo($mvcfile->FileName);
    51. echo("<br/>FileSize : ");
    52. echo($mvcfile->FileSize);
    53. echo("<br/>FilePath : ");
    54. echo($mvcfile->FilePath);
    55. echo("</div>");
    56. //Moves the uploaded file to a new location.
    57. $mvcfile->MoveTo("$dir");

    58. //Copys the uploaded file to a new location.
    59. //$mvcfile->CopyTo("/uploads");
    60. //Deletes this instance.
    61. //$mvcfile->Delete();
    62. }
    63. }
    64. }
    65. ?>
    66. </div>
    67. </body>
    68. </html>

     Also, I had trouble moving the file to a relative location, so I am showing the code (in yellow) that I added to get an absolute location for the file. Even though the control POSTs the data, notice that you can add your own parameters as GET parameters.
     
     
View Complete Thread