title: PHP. Upload .gif file to server
body: <p>My assignment requires me to let users upload .gif file extensions to a folder, and display them after they upload it.</p>
  
  <p>I got the form and processing page, but I cant seem to get them to work. I set the permissions on the directory to rwxrwxrwx to test it out.</p>
  
  <p>Upload file code:</p>
  
  <pre><code>&lt;html&gt;
    &lt;head&gt;
  &lt;title&gt;Assignment 7 Part II -- Art Gallery&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;form method="post" action="a7a2.php" enctype="multipart/form-data"&gt;
      &lt;input type="hidden" name="MAX_FILE_SIZE" value="50000"&gt;
      Your file: &lt;input type="file" name="uploadFile" /&gt;&lt;br /&gt;
      &lt;input type="submit" value="Upload it"&gt;
    &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>&lt;html&gt;
        &lt;head&gt;
          &lt;title&gt;Assignment 7 Part II -- Art Gallery Results&lt;/title&gt;
        &lt;/head&gt;
        &lt;body&gt;
  
        &lt;?php
        $uploadDir = 'images/';
        $uploadFileDir = $uploadDir . basename($_FILES['uploadFile']['name']);                                                   
        if(isset($_FILES['uploadFile'])) {
            if($_FILES['uploadFile']['error'] != UPLOAD_ERR_OK ||
            $_FILES['uploadFile']['mime'] != "image/gif") {
            print "&lt;p&gt;File not uploaded successfully!&lt;/p&gt;";
            print "&lt;p&gt;Please make sure the file has the correct file extension: .gif&lt;/p&gt;"; 
            print "&lt;p&gt;&lt;a href='a7p2.php'&gt;Try uploading again&lt;/a&gt;";
            var_dump($_FILES['uploadFile']['error']);
            die;
            } else {
            move_uploaded_file($_FILES['uploadFile']['name'], $uploadFileDir) or die("Can't move file to $uploadFileDir");   
            print "&lt;p&gt;Success!&lt;/p&gt;";
            }
        }
  
        $uploadedFiles = glob("/students/ryan/php/images/*.gif");
        if($uploadedFiles != false) {
            print "&lt;p&gt;Here are pictures from the art gallery: &lt;/p&gt;";
            foreach($uploadedFiles as $file) {
            $url = "http://hills.ccsf.edu/~ryan/images/" . substr($file, strrpos($file, '/') + 1);
            print "&lt;p&gt;&lt;img src=\"$url\"&gt;&lt;/p&gt;";
            }
        } else {
            print "There are no pictures in the art gallery";
        }
        ?&gt;
  
        &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>or same code, link to the code below:</p>
  
  <p><a href="http://pastebin.com/JNxwy323" rel="nofollow">http://pastebin.com/JNxwy323</a></p>