PHP code example of adt / files
1. Go to this page and download the library: Download adt/files library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
adt / files example snippets
use ADT\Files\Entities\IFileEntity;
use ADT\Files\Entities\TFileEntity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
*/
class File implements IFileEntity
{
use TFileEntity;
}
// create instance of entity
$file = new File();
// set binary data to entity as variable
$file->setTemporaryContent($binaryContentInString, $originalFileName);
// or set path to temporary file, for example after receiving submitted form with file input
$file->setTemporaryFile($pathToTemporaryFile, $originalFileName);
$entityManager->persist($file);
$entityManager->flush();