title: PHP - Resize image on upload AND keep original
body: <p>I'm creating a site using Laravel 4, which allows an admin to upload a large number of images at a time. Currently, I'm able to do just that, where each image is given its own unique ID and put into its own folder named with the same ID. </p>
  
  <p>The problem is that I need the application to also upload a second, resized (smaller) version of the image along with the original. I learned that you must resize an image on the client side, so I'm not sure how I would go about saving the original image, as well as smaller version. The smaller image should be named using the same ID, with some sort of identifier like "-smaller" at the end of the name.</p>
  
  <p>Here's my current front end;</p>
  
  <pre><code>    {{ Form::open(array('url' =&gt; 'imageUpload', 'files' =&gt; true, 'method' =&gt; 'post'))}}
  
                      &lt;div class="form-group"&gt;
                        &lt;label for="fileToUpload" class="col-sm-2 control-label"&gt;Choose All Images&lt;/label&gt;
                      &lt;/br&gt;
                        {{ Form::file('images[]', ['multiple' =&gt; true]) }}
                      &lt;/div&gt;
  
                      &lt;div class="col-sm-offset-2 col-sm-10"&gt;
                        {{ Form::submit('Add Photos', ['class' =&gt; 'btn btn-large btn-primary openbutton'])}}
                        &lt;!--&lt;button type="submit" class="btn btn-default"&gt;Sign in&lt;/button&gt; --&gt;
                      &lt;/div&gt;
  
  {{ Form::close() }} 
  </code></pre>
  
  <p>And here's my controller;</p>
  
  <pre><code>    $files = Input::file('images');
  
      foreach($files as $file) {
          $rules = array(
             'file' =&gt; 'required|mimes:png,gif,jpeg,txt,pdf,doc,rtf|max:9999999999'
          );
          $validator = \Validator::make(array('file'=&gt; $file), $rules);
          if($validator-&gt;passes()){
  
              $id = Str::random(14);
              $id = $race . "-" . $id;
  
              $destinationPath = 'raceImages/' . $id;
              //$filename = $id;
              $filename = $file-&gt;getClientOriginalName();
              $mime_type = $file-&gt;getMimeType();
              $extension = $file-&gt;getClientOriginalExtension();
              $upload_success = $file-&gt;move($destinationPath, $id);
  
  
              );
          } else {
              return Redirect::back()-&gt;with('error', 'I only accept images.');
          }
      }
  </code></pre>