title: PHP - Create a folder and save an image to that folder? Then display that photo?
body: <p>This seems like a big question, and it is, but the majority is done but I'm lost in actually getting where I want to be.</p>
  
  <p>I have the upload form ready and it works, it saves it to a folder named upload, but I need it to create a folder depending on the hotel name that is saved in my session. This is displayed on the page to tell users what session they are on. So now when they save I need it to create the folder named after it to save it to that directory. So here is the code for the HTML :</p>
  
  <pre><code>&lt;span class="prettyFile"&gt;
                                      &lt;form id="form" action="assets/php/upload.php" method="post" enctype="multipart/form-data"&gt;  
                                          &lt;div class="fileupload fileupload-new" data-provides="fileupload"&gt;
                                            &lt;div class="input-append"&gt;
                                              &lt;div class="uneditable-input span3" style="margin-top: -3px;"&gt;&lt;i class="icon-file fileupload-exists"&gt;&lt;/i&gt; &lt;span class="fileupload-preview"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="btn btn-file btn-success"&gt;&lt;span class="fileupload-new"&gt;Upload File&lt;/span&gt;&lt;span class="fileupload-exists"&gt;Change&lt;/span&gt;&lt;input type="file" name="file" /&gt;&lt;/span&gt;&lt;a href="#" class="btn fileupload-exists btn-success" style="margin-top: -3px;" data-dismiss="fileupload"&gt;Remove&lt;/a&gt;
                                              &lt;button type="submit" name="submit" class="btn btn-primary fileupload-exists" value="Upload"&gt;&lt;i class="icon-cloud-upload"&gt;&lt;/i&gt; Upload&lt;/button&gt;
                                            &lt;/div&gt;
                                          &lt;/div&gt;
                                      &lt;/form&gt;
                                  &lt;/span&gt;
  </code></pre>
  
  <p>And here is the PHP:</p>
  
  <pre><code>&lt;?php
  $allowedExts = array("gif", "jpeg", "jpg", "png");
  $temp = explode(".", $_FILES["file"]["name"]);
  $extension = end($temp);
  if ((($_FILES["file"]["type"] == "image/gif")
  || ($_FILES["file"]["type"] == "image/jpeg")
  || ($_FILES["file"]["type"] == "image/jpg")
  || ($_FILES["file"]["type"] == "image/pjpeg")
  || ($_FILES["file"]["type"] == "image/x-png")
  || ($_FILES["file"]["type"] == "image/png"))
  &amp;&amp; ($_FILES["file"]["size"] &lt; 10000000)
  &amp;&amp; in_array($extension, $allowedExts))
      if (file_exists("upload/". $_SESSION['curHotelName'] . "/" . $_FILES["file"]["name"]))
          {
            echo "&lt;script language='javascript'&gt;\n";
            echo "alert('This file exists! Please select a different file.'); window.location.href='https://hotelmobidev.jvgames.com/profile';";
            echo "&lt;/script&gt;\n";
          }
          else
          {
            move_uploaded_file($_FILES["file"]["tmp_name"],
            "upload/". $_SESSION['curHotelName'] . "/" . $_FILES["file"]["name"]);
            echo "&lt;script language='javascript'&gt;\n";
            echo "alert('Success!'); window.location.href='https://hotelmobidev.jvgames.com/profile';";
            echo "&lt;/script&gt;\n";
          } 
  ?&gt;
  </code></pre>
  
  <p>I'm still messing with it but if someone can bump me in the right direction that would be awesome! Thanks guys!</p>