-
Notifications
You must be signed in to change notification settings - Fork 2
File Validation Service Setup
Taha Ansari edited this page Apr 13, 2017
·
2 revisions
Download: https://github.com/Taha5582/VirtualSubmissionAgent/blob/master/fileValidator.php
In order to use the file validation service, add the file validator file php file to the codebase and include the path to it in the controller that is calling it.
Ex: include "fileValidator.php";
There are prerequisite variables that need to be setup for each service feature before the service can be used. They can be passed to the php file using the service by either a request in Laravel (request->fileFieldName) or the $_FILE php superglobal.
- uploadDir: The directory you want to store all uploads in.
- fileName: The name of the file being passed for extraction/uploading.
- trimFileName: Trimmed filename for naming the file in the upload directory.
- tmpName: Temporary file name that holds the extraction information for the file.
- teacherDirPath: Path to the directory where the teachers directory has been uploaded
All these functions return true on success, false on failure. dirCompare returns true on directory structure match, false on failure to match directory structures.
| Function | Use |
|---|---|
| typeCheck | Compares a file with an array of accepted extensions to check the file against |
| uploadFile | Moves a file to a specified upload path |
| extractFiles | Extracts a file to a specific file name at a specified path |
| dirCompare | Compares two directories for structure matching given their specified paths |

