File Upload in Userfrosting
<p>We need to have the user upload an image as a part of sign up process.</p>

<p>Had tried accessing $_FILES['filename'] in the controller, which turns out to be undefined under slim.</p>

<p>Had seen about Slim's way of file uploading in a couple of articles, which are reported to be working, but I hit the wall.</p>

<p>The twig part works fine with <a href="http://plugins.krajee.com/file-basic-usage-demo" rel="nofollow">Bootstrap File Input library</a></p>

<p>For the server part using <a href="https://github.com/brandonsavage/Upload" rel="nofollow">File Upload library for Slim</a></p>

<p>Controller code (modifications to AccountController) looks like this</p>

<pre><code>...
$storage = new \Upload\Storage\FileSystem('c:/xampp/htdocs/userfrosting/public/images/');
$file = new \Upload\File('imagefile', $storage);

$new_filename = 'test.jpg';
$file-&gt;setName($new_filename);

$file-&gt;addValidations(array(
    // Ensure file is of type "image/jpg"
    new \Upload\Validation\Mimetype('image/jpg'),
    // Ensure file is no larger than 500K (use "B", "K", M", or "G")
    new \Upload\Validation\Size('500K')
));

// Access data about the file that has been uploaded
$uploadfiledata = array(
    'name' =&gt; $file-&gt;getNameWithExtension(),
    'extension' =&gt; $file-&gt;getExtension(),
    'mime' =&gt; $file-&gt;getMimetype(),
    'size' =&gt; $file-&gt;getSize(),
    'md5' =&gt; $file-&gt;getMd5(),
    'dimensions' =&gt; $file-&gt;getDimensions()
);
error_log('$uploadfiledata' . print_r($uploadfiledata, true));
// Try to upload file
try {
    // Success!
    $file-&gt;upload();
} catch (\Exception $e) {
    // Fail!
    $errors = $file-&gt;getErrors();
}
...
</code></pre>

<p>This returns the following error,</p>

<blockquote>
  <p>Type: InvalidArgumentException</p>
  
  <p>Message: Cannot find uploaded file identified by key: imagefile</p>
  
  <p>File: C:\xampp\htdocs\userfrosting\userfrosting\vendor\codeguy\upload\src\Upload\File.php</p>
  
  <p>Line: 139</p>
</blockquote>

<p>The relevant twig chunk is </p>

<pre><code>&lt;input id="imagefile" type="file" name="imagefile"  class="file" data-show-upload="false"&gt;
</code></pre>

<p>Has anyone been able to get file upload working as a part of any Userfrosting code?</p>

<p>Appreciate any help / pointers.</p>

<p>Thanks!</p>