About SaveDirectory

Last post 10-26-2012, 4:51 PM by DongZheng. 2 replies.
Sort Posts: Previous Next
  •  10-25-2012, 8:39 PM 75058

    About SaveDirectory

    Hi

     

    We need help to define the savedirectory. In the test, we put test.php and phpfileuploader to c:\phptest\fileupload. add myfolder under fileupload. If set SaveDirectory = "myfolder" ($uploader->SaveDirectory="myfolder";), then file uploading works fine. 

     

    However, if we set up another myfolder directly under phptest (c:\phptest\myfolder), how can I define the SaveDirectory? I tried the following:

     

    $uploader->SaveDirectory="../myfolder"; 

     

    It fails. Can some advise? Thanks. 

    Filed under:
  •  10-26-2012, 8:05 AM 75073 in reply to 75058

    Re: About SaveDirectory

    Hi DongZheng,

     

    I suggest you use method "CopyTo" to handle the upload file store location, 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/test/".$mvcfile->FileName);   
    40.         }      
    41.     }      
    42.   
    43. }  
    44. ?>  
    45.   
    46.         </div>  
    47.     </body>  
    48. </html>  
     

    Regards,

     

    Ken 

  •  10-26-2012, 4:51 PM 75079 in reply to 75073

    Re: About SaveDirectory

    Cool, thanks.

     

    Dong 

    Filed under:
View as RSS news feed in XML