Contents

 
Home
PHPRunner 6.0 manual
Prev Page Next Page
 
 

Upload files to users folders

 

To upload files to a personal user folder use the following code in Add page: Before record added and/or Edit page: Before record updated events.

User folders will be created in the files folder or any other folder stated in the Visual Editor -> Field properties. For more information about setting files folder, see "View as" settings: File. Note that web server user must have write permissions on the upload folder and all its subfolders.

yellowbulbNote: Change the values listed in red to match your specific needs.

//username is used as directory name

global $pageObject;

foreach( $pageObject->filesToMove as $key=>$val)

{

 if($pageObject->filesToMove[$key]->sourceFilename==$_FILES["value_FieldName_".postvalue("id")]["tmp_name"])

 {

    //create directory if don't exist

    $dirname= "files/".$_SESSION["UserID"];

    if (is_dir($dirname)) {

    } else {

       mkdir("files/".$_SESSION["UserID"], 0777);

    }

   $pageObject->filesToMove[$key]->destFilename =

    $_SESSION["UserID"]."/".$values["FieldName"];

 }

}

$values["FieldName"] = $_SESSION["UserID"]."/".$values["FieldName"];

In this example FieldName stores the name of uploaded file.

 

 

 

 

Converted from CHM to HTML with chm2web Standard 2.85 (unicode)