nefunkcni fuknce move u uploadu
- cvit84
- Člen | 43
Zravim potreboval bych rozchodit funkci move a ukladani souboru.
V presenteru mam toto:
use Models\Upload\Upload;
public function fileUploadFormSucceded(UI\Form $form, Nette\Utils\ArrayHash $values): void {
foreach ($values->files as $fileUpload){
if($fileUpload->isOk()){
$path = '/upload';
$upload = new Upload($path);
$upload->save($fileUpload);
;
}
}
}
V neonu mam toto
parameters:
uploadDir: '%appDir%/../upload'
application:
errorPresenter: Error
session:
expiration: 14 days
extensions:
visualPaginator: IPub\VisualPaginator\DI\VisualPaginatorExtension
services:
router: App\Router\RouterFactory::createRouter
autheticator: Models\Security\Autheticator
authorizator: Models\Security\Acl
- Models\Db\DbAccessManager
- Models\Upload\Upload(%uploadDir%)
a soubor upload vypada takto
namespace Models\Upload;
use Models\Form\BootstrapForm;
use Nette\Application\UI\Form;
use Nette\Utils\ArrayHash;
use Nette;
use Nette\Application\UI;
use Nette\Http\FileUpload;
use Tracy\Debugger;
use AdminModule\OfferPresenter;
use Models\Db\DbFile;
class Upload {
private $path;
public function __construct($path) {
$this->path =$path;
}
public function save(FileUpload $file) { /*dalsi parametry DbFile $dbFile*/
$file_name= md5($file->getContents());
$file->getContentType();
$file->getName();
$suffix='.x';
$file->move($this->path. DIRECTORY_SEPARATOR.$file_name.$suffix);
Debugger::barDump($this->path. DIRECTORY_SEPARATOR.$file_name.$suffix);
}
problem je ten ze fuknce save, respektive move mi problikne a nic neulozi adresar pro upload mam app/upload nevim jak tam mam dat tu cestu zkousim vsechno mozne a jsem z toho na vetvi. Budu rad za jakoukoliv radu.
- cvit84
- Člen | 43
MajklNajt napsal(a):
pozri konfiguráciu PHP-ka, akú máš nastavenú hodnotu pri
upload_max_filesize
apost_max_size
(musí byť väčšie ako limit pre upload)
To mam v poradku. Mam to nastavene na 40 mega. Spise davam blbe cestu. Nevim jak ji tam mam dat. Zkousel jsem vselijake zapisy a marne. Ani nevim jak to dumpnout, nebo vytrasovat. :(