====== RestRequest::getFileParameters() ======
----
===== Definition =====
Returns the file parameters of the request as array. This array can contain 0 - n file content datasets received from client (usually via POST or PUT). \\
File parameters are set, if the client sends/uploads one or more files to the webservice.
**Important!** The upload form has to contain the mandatory attribute ''enctype="multipart/form-data"'' otherwise the upload will not work because only the filename and no content is transfered.
Array getFileParameters ( )
===== Returns =====
* **Array** \\ Array, containing 0 - n elements with each containing an array with information about one uploaded file.
**Array elements:**
|<100% 30% 70%>|
| ''array[n]['name']'' | Original filename at the client's system. |
| ''array[n]['type']'' | MIME type of the file. The type is not checked and forwarded exactly as it is received from the client. |
| ''array[n]['size']'' | Byte size of the received file. |
| ''array[n]['tmp_name']'' | Temporary filename (incl. path) with which the file was stored at the server. ((The webserver always stores the upladed file with a unique filename in the webservers tmp folder where it can be accessed for further processing)) |
| ''array[n]['error']'' | Errorcode of the file transfer. |
===== Example =====
$Request = new RestRequest();
// Called endpoint is: [PUT] https://www.domain.com/webservice/accounting/booking/
// Uploaded file is: "dataset.csv" (file content: "id:5,account:1234,name:Mr. Smith,amount:592.30")
$Application = $Request->getApplication(); // "accounting"
$Method = $Request->getMethod(); // "booking"
if ( $Request->hasFileParameters() ) // true
{
$FirstFileParams = $Request->getFileParameters()[0]; // array ('name' => 'dataset.csv', 'size' => 46 etc.)
$OriginalFilename = $FirstFileParams['name']; // "dataset.csv"
$UploadFileLocation = $FirstFileParams['tmp_name'] // "/usr/local/www/tmp/f23dJsefgs.dat"
$FileContent = file_get_contents ( $UploadFileLocation ); // "id:5,account:1234,name:Mr. Smith,amount:592.30"
}
~~NOTOC~~