Adding fields and saving to DB

Last post 12-10-2012, 7:42 AM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  12-07-2012, 3:18 PM 75424

    Adding fields and saving to DB

    I have tested Simple Upload with Progress and Multiple file uploads and I have managed to upload files to the server. Both works fine. However the problem is these only save the files to server. But I need to save the Uploaded File Names to database. I also need to add couple of fields to collect customers' Name and Email and save them to database too (with the uploaded file name).  I am not sure how to achieve it as I am more of a graphic designer than a web develovper. Any help would be much appreciated.
  •  12-10-2012, 7:42 AM 75431 in reply to 75424

    Re: Adding fields and saving to DB

    Hi shafi01,

     

    Please try the example below. You can save the upload file name when page postback.

     

    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.             example 
    8.         </title> 
    9.     </head> 
    10.     <body> 
    11.  
    12.         <form id="form1" method="POST"
    13.             <?php                 
    14.                     $uploader=new PhpUploader(); 
    15.                     $uploader->MaxSizeKB=10240; 
    16.                     $uploader->Name="myuploader"
    17.                     $uploader->InsertText="Select multiple files (Max 10M)"
    18.                     $uploader->AllowedFileExtensions="*.jpg,*.png,*.gif,*.txt,*.zip,*.rar";   
    19.                     $uploader->MultipleFilesUpload=true; 
    20.                     $uploader->Render(); 
    21.  
    22.             ?> 
    23.  
    24.         </form> 
    25.  
    26.  
    27.         <?php 
    28. $fileguidlist=@$_POST["myuploader"]; 
    29. if($fileguidlist
    30. $guidlist=explode("/",$fileguidlist);    
    31.     foreach($guidlist as $fileguid)     
    32.     {     
    33.          
    34.         //get the uploaded file based on GUID        
    35.         $mvcfile=$uploader->GetUploadedFile($fileguid);        
    36.         if($mvcfile)        
    37.         {        
    38.         //save file name in db here 
    39.     //$mvcfile->FileName is the upload file name 
    40.         }     
    41.     }     
    42.  
    43. ?> 
    44.  
    45.         </div> 
    46.     </body> 
    47. </html> 
     

    Regards,

     

    Ken

View as RSS news feed in XML