Upload Off-Site

-4

WellI'mkindofconfusedherebecauseI'mcreatingthefolderbutatthetimeofupaitupaonelevelabove.Whereistheerror?

if(is_uploaded_file($_FILES["foto"]["tmp_name"])) {
mkdir("../img/$Npasta") or die("erro ao criar diretório $Npasta");
$foto = time() . '_' . $_FILES["foto"]["name"];
$diretorio = '../img/$Npasta';
$dirfoto = $diretorio.$foto;

if (!move_uploaded_file($_FILES["foto"]["tmp_name"], $dirfoto)) {
  $error = TRUE;
 }
}

Addendum: I am creating the dynamic folders by taking the last id of the bank by adding + 1 and the folder is being created, so I can not understand it at the time of loading the variable seems to be "lost" because as you see the name stays $ Npasta.taltaltaltal.jpg where that would actually have to be img / 4 / nomedoarquivoupado.jpg

    
asked by anonymous 03.10.2015 / 19:38

1 answer

1

You can do this too:

if(is_uploaded_file($_FILES["foto"]["tmp_name"])) {
    mkdir("../img/".$Npasta) or die("erro ao criar diretório $Npasta");
        $foto = time() . "_" . $_FILES["foto"]["name"];
        $diretorio = "../img/".$Npasta."/";
        $dirfoto = $diretorio.$foto;

    if (!move_uploaded_file($_FILES["foto"]["tmp_name"], $dirfoto)) {
        $error = TRUE;
        echo "Imagem não enviada!";
    }
}
    
03.10.2015 / 19:49