How can I change SaveDirectory dinamically through javascript function ¿?

Last post 12-31-2012, 11:22 AM by Kenneth. 1 replies.
Sort Posts: Previous Next
  •  12-28-2012, 12:22 PM 75560

    How can I change SaveDirectory dinamically through javascript function ¿?

    Hello.

    I would like to know if it's possible change SaveDirectory attribute  once the object myuploader have been created throught a javascript function,..., with out load again the page. 

     

    My example: (A page for save in database materials)

    When my page it's loaded, the default SaveDirectory it's --> files/tmp_files.

    When the user want create a new type of material, fill the form fields and upload files of this material,  that are saved in files/tmp_files :)... all right. Then the user save the new material, I register the new material in my database, and with the id of the material, I create a new folder and move,he files from tmp_files to this new path. -> for example files/material_cod_36

     

    following the example, if user want add new files to material 36... I would like to change  myuploader->SaveDirectory to files/material_cod_36 with out load again the page..., with a javascript function.

     

    I hope it's clear, and you will can help me.

     

    Thanks :).

     

  •  12-31-2012, 11:22 AM 75564 in reply to 75560

    Re: How can I change SaveDirectory dinamically through javascript function ¿?

    Hi,

     

    I suggest you handle the upload file store location by method "Copyto", like the exmaple 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.             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. {  
    31. $guidlist=explode("/",$fileguidlist);     
    32.     foreach($guidlist as $fileguid)      
    33.     {      
    34.           
    35.         //get the uploaded file based on GUID         
    36.         $mvcfile=$uploader->GetUploadedFile($fileguid);         
    37.         if($mvcfile)         
    38.         {         
    39.         $mvcfile->CopyTo("D:/sites/phpuploader/upload/".$mvcfile->FileName);   
    40.         }      
    41.     }      
    42.   
    43. }  
    44. ?>  
     

    Regards,

     

    ken 

View as RSS news feed in XML