slim - File Upload in Userfrosting -


we need have user upload image part of sign process.

had tried accessing $_files['filename'] in controller, turns out undefined under slim.

had seen slim's way of file uploading in couple of articles, reported working, hit wall.

the twig part works fine bootstrap file input library

for server part using file upload library slim

controller code (modifications accountcontroller) looks this

... $storage = new \upload\storage\filesystem('c:/xampp/htdocs/userfrosting/public/images/'); $file = new \upload\file('imagefile', $storage);  $new_filename = 'test.jpg'; $file->setname($new_filename);  $file->addvalidations(array(     // ensure file of type "image/jpg"     new \upload\validation\mimetype('image/jpg'),     // ensure file no larger 500k (use "b", "k", m", or "g")     new \upload\validation\size('500k') ));  // access data file has been uploaded $uploadfiledata = array(     'name' => $file->getnamewithextension(),     'extension' => $file->getextension(),     'mime' => $file->getmimetype(),     'size' => $file->getsize(),     'md5' => $file->getmd5(),     'dimensions' => $file->getdimensions() ); error_log('$uploadfiledata' . print_r($uploadfiledata, true)); // try upload file try {     // success!     $file->upload(); } catch (\exception $e) {     // fail!     $errors = $file->geterrors(); } ... 

this returns following error,

type: invalidargumentexception

message: cannot find uploaded file identified key: imagefile

file: c:\xampp\htdocs\userfrosting\userfrosting\vendor\codeguy\upload\src\upload\file.php

line: 139

the relevant twig chunk

<input id="imagefile" type="file" name="imagefile"  class="file" data-show-upload="false"> 

has been able file upload working part of userfrosting code?

appreciate / pointers.

thanks!

my guess you're using ufformsubmit submit registration form, , not grabbing file input. so, need add code on client side explicitly submit file input along rest of form. see example using dropzone , uf: https://gist.github.com/frostbitten/c1dce70023321158a2fd#file-upload-twig

by way, can use browser see data actually being sent in post request. example, in firefox can use network monitor.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -