Q:

Image uploading using php not working

I was just trying to create a simple image uploading script. 
This is what I used, but it seems there is some problem and shows an error
<?php
    define("FILEREPOSITORY", "./");
    if(isset($_POST['submit'])){
        $user =$_POST['user'];
        $ext_boo = FALSE;
        $size_boo = FALSE;
        $user_boo = FALSE;
        if(strlen($user)<=0){
            echo "No Username";
            $user_boo = FALSE;
        }
        if($_FILES['picture']['size'] <=1024000){
            $size_boo = TRUE;
        }
        else{
            echo "Too large";
            $size_boo = FALSE;
        }
        if(is_uploaded_file($_FILES['picture']['tmp_name'])){
            //mime type
            switch($_FILES['picture']['type']){
                case "image/jpeg":
                    $extension = ".jpeg";
                    $ext_boo = TRUE;
                    break;
                case "image/gif":
                    $extension = ".gif";
                    $ext_boo = TRUE;
                    break;
                case "image/png":
                    $extension = ".png";
                    $ext_boo = TRUE;
                    break;
            }
            if($ext_boo && $size_boo && $user_boo){
                $result = move_uploaded_file($_FILES['picture']['tmp_name'], FILEREPOSITORY."/images/".$user."".$extension."");
                if($result)
                    echo "Uploaded";
                else
                    echo "Some problems";
            }
        echo "Wrong file type";
        }
    }
    else{
        echo "<table>
        <form enctype=\"multipart/form-data\" action=\"\" method=\"post\">
        <tr>
        <td>User:</td>
        <td><input type=\"test\" name=\"user\" /></td>
        </tr>
        <tr>
        <td>File:</td>
        <td><input type=\"file\" name=\"picture\" /></td>
        </tr>
        <input type=\"submit\" name=\"submit\" value=\"upload\" />
        </form>
        </table>";
    }
?>

Can anybody help me to find out the problem?
Error after trying var_dump($_FILES);:
array (size=1)
  'picture' => 
    array (size=5)
      'name' => string 'sample.png' (length=10)
      'type' => string 'image/png' (length=9)
      'tmp_name' => string 'C:\wamp\tmp\php74BB.tmp' (length=23)
      'error' => int 0
      'size' => int 7575
Wrong file type

A:

You never set $user_boo to TRUE anywhere. I switched it to start off as TRUE (assume it is true until you later check to see if it's false on line 10).
Also on line 37 I changed the file path. You had an extra / in your upload location. Code below worked on my machine. Make sure you have the www user set to owner on whatever location you are trying to upload to and that it has permissions to write.
<?php
    define("FILEREPOSITORY", "./");
    if(isset($_POST['submit'])){
        $user =$_POST['user'];
        $ext_boo = FALSE;
        $size_boo = FALSE;
        $user_boo = TRUE;
        if(strlen($user)<=0){
            echo "No Username";
            $user_boo = FALSE;
        }
        if($_FILES['picture']['size'] <=1024000){
            $size_boo = TRUE;
        }
        else{
            echo "Too large";
            $size_boo = FALSE;
        }
        if(is_uploaded_file($_FILES['picture']['tmp_name'])){
            //mime type
            switch($_FILES['picture']['type']){
                case "image/jpeg":
                    $extension = ".jpeg";
                    $ext_boo = TRUE;
                    break;
                case "image/gif":
                    $extension = ".gif";
                    $ext_boo = TRUE;
                    break;
                case "image/png":
                    $extension = ".png";
                    $ext_boo = TRUE;
                    break;
            }
            var_dump($ext_boo,$size_boo,$user_boo);
            if($ext_boo && $size_boo && $user_boo){
                $result = move_uploaded_file($_FILES['picture']['tmp_name'], FILEREPOSITORY."images/".$user."".$extension."");
                if($result)
                    echo "Uploaded";
                else
                    echo "Some problems";
            }
        echo "Wrong file type";
        }
    }
    else{
        echo "<table>
        <form enctype=\"multipart/form-data\" action=\"\" method=\"post\">
        <tr>
        <td>User:</td>
        <td><input type=\"test\" name=\"user\" /></td>
        </tr>
        <tr>
        <td>File:</td>
        <td><input type=\"file\" name=\"picture\" /></td>
        </tr>
        <input type=\"submit\" name=\"submit\" value=\"upload\" />
        </form>
        </table>";
    }
?>

