← Back
Editing: Upload.php
<?php namespace App\Service; class Upload { private $targetDirectory; public function __construct($targetDirectory) { $this->targetDirectory = $targetDirectory; } /** * Retourne le chemin d'upload. */ public function getPath(string $folder): string { if (!is_dir($this->targetDirectory.'/'.$folder)) { mkdir($this->targetDirectory.'/'.$folder); } return $this->targetDirectory.'/'.$folder; } public function saveBase64File($string, string $ext, string $controleUid): string { $name = uniqid().'.'.$ext; file_put_contents($this->getPath($controleUid).'/'.$name, base64_decode($string)); return $controleUid.'/'.$name; } }
Save File
Cancel