<?php
function loadImageAds() {
    $path = "imgdir";
    
    // 該当ディレクトリの確認
    if(!file_exists($path)){
        if(mkdir($path, 0777))
            echo "Directory Created <br/>";
    }else{
        if(chmod($path, 0777))
            echo "Directory Permission Modified <br/>";
    }
            
    $saveName = basename($_FILES["img1"]["name"]);
            
    print_r($_FILES);
    
    if(move_uploaded_file($_FILES["img1"]["tmp_name"], "{$path}/{$saveName}")) {
        chmod("{$path}/{$saveName}", 0777);
        
        return true;
    }
            
    return false;
}


if(loadImageAds()){
    echo "<br/><br/>File Uploaded!";
}