1
Hello, I am making a system where I previously create a folder, and later I upload the file (later I will treat whether it is image or video), the problem is that the method move_uploaded_file
is ignoring variables after the first bar and uploading to the first folder, not to the user-defined folder:
$nome_pasta = $_POST['pasta']; //É o nome da pasta que o usuário criou na tela anterior do meu sistema.
if (isset($_POST['pasta'])){
try{
mkdir('./public/'. $nome_pasta) or die("erro ao criar diretório"); // Cria uma nova pasta dentro do diretório atual
} catch (Exception $e){
echo 'Exceção capturada: ', $e->getMessage(), "\n";
}
}
foreach ($_FILES["files"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$tmp_name = $_FILES["files"]["tmp_name"][$key];
$name = $_FILES["files"]["name"][$key];
move_uploaded_file($tmp_name, "public/$nome_pasta/$name" );
}
}
I tried against bar but there was no feeling either... any idea?
If you really try:
move_uploaded_file($tmp_name, "public/Teste/$name" );
he does the supposed?– Miguel
The man I mistook for the answer...
– MagicHat