Manual Upload - So I can upload file and save fields

Last post 06-25-2012, 6:13 AM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  06-24-2012, 5:36 AM 73983

    Manual Upload - So I can upload file and save fields

    Hi,
     
    I am using UploadAttachments
     
    I need to be able to do a manual upload as I want the user to select a file and enter various other bits of information. Then when the user selects the submit button I want the file and fields to be submitted so that I can save the file to the file system and the fields to a database.
     
    I have tried ManualStartUpload = False
     
    and that stops the auto uploading, but how do I actually start the upload once the user clicks the page save button.
     
    The manual upload demo seems to do something like what I need but I cannot see the source code that makes that work.
     
    None of the demos show the source code necessary to get the demonstrated behaviour.
     
    Many thanks
    Derek 
    Filed under: , ,
  •  06-25-2012, 6:13 AM 73997 in reply to 73983

    Re: Manual Upload - So I can upload file and save fields

    Hi derekml,
     
    You can find all source code of the demo in the php uploader demo package.
     
    Demo package download url: http://www.cutesoft.net/downloads/folders/52443/download.aspx 
     
    I also attached the manual start upload example code below. 
    1. <?php require_once "phpuploader/include_phpuploader.php" ?>  
    2. <?php session_start(); ?>  
    3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  
    4. <html xmlns="http://www.w3.org/1999/xhtml">  
    5. <head>  
    6.     <title>  
    7.         Form - Start uploading manually  
    8.     </title>  
    9.               
    10.     <script type="text/javascript">  
    11.     function doStart()  
    12.     {  
    13.         var uploadobj = document.getElementById('myuploader');  
    14.         if (uploadobj.getqueuecount() > 0)  
    15.         {  
    16.             uploadobj.startupload();  
    17.         }  
    18.         else  
    19.         {  
    20.             alert("Please browse files for upload");  
    21.         }  
    22.     }  
    23.     </script>  
    24.       
    25. </head>  
    26. <body>  
    27.       
    28.             <form id="form1" method="POST">  
    29.                 <?php      
    30.                     $uploader=new PhpUploader();  
    31.                     $uploader->Name="myuploader";  
    32.                     $uploader->InsertText="Select multiple files (Max 1000M)";  
    33.                     $uploader->AllowedFileExtensions="*.jpg,*.png,*.gif,*.txt,*.zip,*.rar";    
    34.                     $uploader->MultipleFilesUpload=true;  
    35.                     $uploader->ManualStartUpload=true;  
    36.                     $uploader->Render();  
    37.                 ?>  
    38.                 <br /><br /><br />  
    39.                 <button id="submitbutton" onclick="doStart();return false;">Start Uploading Files</button>  
    40.   
    41.             </form>  
    42.               
    43.             <br/><br/><br/>  
    44. <?php  
    45. $fileguidlist=@$_POST["myuploader"];  
    46. $item = @$_POST["text1"];  
    47. if($fileguidlist)  
    48. {  
    49.     $guidlist=explode("/",$fileguidlist);  
    50.       
    51.     echo("<div style='font-family:Fixedsys;'>");  
    52.     echo("Uploaded ");  
    53.     echo(count($guidlist));  
    54.     echo(" files:");  
    55.     echo("</div>");  
    56.     echo("<hr/>");  
    57.       
    58.     foreach($guidlist as $fileguid)  
    59.     {  
    60.         $mvcfile=$uploader->GetUploadedFile($fileguid);  
    61.         if($mvcfile)  
    62.         {  
    63.             echo("<div style='font-family:Fixedsys;border-bottom:dashed 1px gray;padding:6px;'>");  
    64.             echo("FileName: ");  
    65.             echo($item.$mvcfile->FileName);  
    66.             echo("<br/>FileSize: ");  
    67.             echo($mvcfile->FileSize." b");  
    68.     //      echo("<br/>FilePath: ");  
    69.     //      echo($mvcfile->FilePath);  
    70.             echo("</div>");  
    71.               
    72.             //Moves the uploaded file to a new location.  
    73.             //$mvcfile->MoveTo("/uploads");  
    74.             //Copys the uploaded file to a new location.  
    75.             //$mvcfile->CopyTo("/uploads");  
    76.             //Deletes this instance.  
    77.             //$mvcfile->Delete();  
    78.         }  
    79.     }  
    80. }  
    81. ?>  
    82.                   
    83.     </div>  
    84. </body>  
    85. </html>  
    Regards,
     
    Ken 
     
View as RSS news feed in XML