Function descriptions Function “lmb_fileUpload()” Estimated reading: 5 minutes lmb_fileUpload mixed lmb_fileUpload(array $file,numeric $level,array $relation=null, boolean $uploadfrom=false, array $dublicate=array(),boolen $verbose=false) Function for uploading single or multiple files into the DMS (./limbas_src/extra/explorer/filestructure.lib) Summary of the parameters: Information on the uploaded file using the array $file Target folder Link parameters Optional file source Handling duplicateds Parameters $file Valid parameters of an uploaded file $file[“file”] – string : absolute path of the uploaded file $file[“file_name”] : string – name of the file $file[“file_type”] : string – MIMETYPE of the file $file[“file_archiv”] : boolean – true if zip archive should be unpacked $level Valid folder ID to which the file should be copied $relation Data record or records to which the file should be linked. Fields of the type Link (field_type 11) and Upload (field_type 6) can be used. $relation[“gtabid”][0] : Table ID $relation[“fieldid”][0] : Field ID $relation[“datid”][0] : Data record ID $uploadfrom Authorizes an upload from different sources without prior HTTP upload 1 : import from internal system 2 : import from a local path 3 : import from external storage $duplicate Handles the process if the file already exists. The file name, folder and (if available) the link to a record are used for the duplicate check. The parameter “typ” defines how the file should be handled. The parameter “subj” can optionally contain a description text for versioning. The parameter “existingFileID” can be used to provide a file ID that was found as a duplicate. In some cases you may want to check for yourself whether and which file exists as a duplicate and you can override the system’s internal duplicate search. This is relevant for the extension function “lmb_extendedFileUpload”. $dublicate[“subj”] : version notice if versioning $dublicate[“existingFileID”] : [numeric] $dublicate[“typ”] : overwrite, rename, versioning, skip, ignore overwrite : File is overwritten, name stays the same rename : File is renamed to “Copy of” versioning : File is versioned, name stays the same skip : File is not uploaded or created ignore : File is saved with the same name $verbose true : Forces a detailed output false : The function only specifies the record ID of the imported file Return value Array from the processed file information if $verbose = true $fl[“nextid”] : The assigned data record number of the table LDMB_FILES $fl[“filesize”] : The file size $fl[“filename”] : The final file name $fl[“level”] : The folder ID $fl[‘mimetype_id’] : The MimeType ID of the table LMB_MIMETYPES $fl[‘mimetype’] : The MimeType $fl[‘secname’] : The physical file name with which the file was stored in the file system $fl[“md5”] : The MD5 key of the file $fl[“vpid”] : The record ID of the reference file if the file was versioned Extension The upload function can be redirected via the fixed function lmb_extendedFileUpload(). This requires the function lmb_extendedFileUpload() in an extension file. If this is present, it will be executed at the beginning of the upload process. It can return TRUE or FALSE. If TRUE the file is either processed directly or the parameters are adjusted. If FALSE, the upload process is cancelled. mixed lmb_extendedFileUpload(array &$file, numeric &$level, array &$relation, array &$dublicate) The parameters can be overwritten directly in the function by reference. The following parameters are supported: $file $level $relation $dublicate Examples Example 1 This example uses redirecting with a custom function ‘lmb_extendedFileUpload’ function lmb_extendedFileUpload(&$file, &$level, &$relation, &$dublicate){ // falls in Ordner 4 hochgeladen wird, wird der Name der Datei geändert und der Zielordner geändert. if($level == 4){ $level = 5; $file["file_name"][0] = "myfile_NEW.pdf"; } // falls in Ordner 6 hochgeladen wird, wird die Datei versucht zu konvertieren. if($level == 6){ if($file["file_type"][0] == 'application/pdf' AND file_exists($file["file"][0])){ # IMACK_ConvertThumbs($file,$width=,$height=null,$prop=null,$dest_format=null,$dest_path=null IMACK_ConvertThumbs($file["file_type"][0],300,null,1,null,'/tmp/convert.png'); $file["file"][0] = '/tmp/convert.png'; } // Eigene Duplikatssuche im Ordner ID 4 anstatt Order 6 if($dublicate['existingFileID'][0] = check_duplicateFile($file["file_name"][0], 4)){ $dublicate['typ'][0] = 'overwrite'; } if(file_exists($file["file"][0])){ return true; }else{ return false; } } return true; } Example 2 This example imports a previously uploaded file from the temp folder to the Limbas DMS. The file should be stored in the folder with ID 10 and with the name myfile.pdf. The file should be renamed if the file already exists. After the file is imported, it should be linked to a specific data record. For this, the table must contain a link field with the file explorer extension. $level = 10; $file["file"][0] = '/tmp/htg55565765.tmp'; $file["file_name"][0] = myfile.pdf; $file["file_type"][0] = 'application/pdf'; $dublicate['type'][0] = 'rename'; $relation = array("datid" => $ID,"gtabid" => $gtab_id,"fieldid" => $field_id); $output = lmb_fileUpload($file,$level,relation,null,$dublicate); Example 3 This example imports a file like the previous example with the exception that the file didn’t need to be uploaded since it already exists in the file system. The parameter $uploadfrom forces the file import without executing the check is_uploaded_file(). If it already exists in the DMS, the file is ignored because of the parameter $dublicate[‘type’][0] = ‘skip’. $level = 10; $file["file"][0] = '/mnt/myfiles/mytest.pdf'; $file["file_name"][0] = mytest.pdf; $file["file_type"][0] = 'application/pdf'; $dublicate['type'][0] = 'skip'; $uploadfrom = 2; $output = lmb_fileUpload($file,$level,null,$uploadfrom,$dublicate);