-2
<form action="" method="post" enctype="multipart/form-data">
<input type="file" name="file"/>
<button type="submit">Enviar</button>
</form>
<?php
if ($_SERVER["REQUEST_METHOD"]==="POST"){
$file = isset($_FILES["file"])?$_FILES["file"]:"";
}
$dir ="upload4";
if(!is_dir($dir)){
mkdir($dir);
echo "Pasra criada com sucesso";
}
move_uploaded_file($file["tmp_name"],$dir.DIRECTORY_SEPARATOR.$file["name"]);
In ternary operator could put a
exit
if no file exists, so the code stops and shows no error– Costamilam
where Exit would be located?
– Rebeca Aguirrer