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?
-
- <?php require_once "phpuploader/include_phpuploader.php" ?>
- <!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>
- Form - Multiple files upload
- </title>
- <link href="demo.css" rel="stylesheet" type="text/css" />
-
- <script type="text/javascript">
- function CuteWebUI_AjaxUploader_OnPostback() {
- //submit the form after the file have been uploaded:
- document.forms[0].submit();
- }
- </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>
-
- <!-- do not need enctype="multipart/form-data" -->
- <form id="form1" method="POST">
- <?php
- $uploader=new PhpUploader();
- $uploader->MaxSizeKB=10240;
- $uploader->MultipleFilesUpload=true;
- $uploader->Name="myuploader";
- $uploader->InsertText="Select multiple files (Max 10M)";
- $uploader->Render();
- ?>
- </form>
-
- <br/><br/>
- <?php
- $fileguidlist=@$_POST["myuploader"];
- if($fileguidlist)
- {
$docRoot = $_SERVER['DOCUMENT_ROOT'];//used for reading files
$userName
$dir = "$docRoot/$userName/";
- $guidlist=split("/",$fileguidlist);
-
- echo("<div style='font-family:Fixedsys;'>");
- echo(count($guidlist));
- echo(" files Uploaded:");
- echo("</div>");
- echo("<hr/>");
-
- foreach($guidlist as $fileguid)
- {
- $mvcfile=$uploader->GetUploadedFile($fileguid);
- if($mvcfile)
- {
- echo("<div style='font-family:Fixedsys;border-bottom:dashed 1px gray;padding:6px;'>");
- echo("FileName : ");
- echo($mvcfile->FileName);
- echo("<br/>FileSize : ");
- echo($mvcfile->FileSize);
- echo("<br/>FilePath : ");
- echo($mvcfile->FilePath);
- echo("</div>");
- //Moves the uploaded file to a new location.
-
- $mvcfile->MoveTo("$dir");
- //Copys the uploaded file to a new location.
- //$mvcfile->CopyTo("/uploads");
- //Deletes this instance.
- //$mvcfile->Delete();
- }
- }
- }
- ?>
-
- </div>
- </body>
- </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.