Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $stmt->execute(); -------> final do insert até aki ok
- if (DB::lastInsertId()) {
- // pego o ultimo id
- $lastId = DB::lastInsertId();
- // crio o diretorio
- mkdir ("../img/$lastId", 0755 ); ---> ate aqui ok o diretorio e criado usando o ultimo id
- ---------------------> a partir daqui que esta o problema
- // upload e update
- // altero o nome
- $filename = time() . '_' . $_FILES["imagem"]["name"];
- $diretorio = '../img/$lastId/';
- $filepath = '$diretorio' . $filename;
- move_uploaded_file($_FILES["imagem"]["tmp_name"], $filepath)
- // insere no bd
- $sqlInsert2 = "UPDATE noticias SET imagem=$filename WHERE idnoticia=$lastId";
- $stmt = DB::prepare($sqlInsert2);
- $stmt->bindParam("imagem", $filename);
- $stmt->execute();
- setMessage("Notícia $lastId $filename cadastrado com sucesso.");
- redirect("noticiasListar.php");
- $diretorio = '../img/$lastId/';
- $filepath = '$diretorio' . $filename;
- $diretorio = '../img/' . $lastId . '/';
- $filepath = $diretorio . $filename;
- $sqlInsert2 = 'UPDATE noticias SET imagem = "' . $filename . '" WHERE idnoticia = "' . $lastId . '"';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement