
php, mysql - formulář (text+soubory) - nejde zápis do DB a nahrání souborů do složky
Ahoj. mám formulář, kde mám textareu a pod tím mám možnost vložit 3 soubory. soubory chci vložit do nějaké složky a cestu zapsat do DB. mám toto a nefunguje to:
formulář:
<form method=\"POST\" action=\"scripty/akce.php\" enctype=\"multipart/form-data\">
<div>
<textarea name=\"editor1\"></textarea>
<script type=\"text/javascript\">
CKEDITOR.replace( 'editor1' );
</script>
</div>
<div>
<table>
<tr>
<td>Můžete přiložit 3 fotky.</td>
</tr>
<tr>
<td><input name=\"jpg1\" type=\"file\"></td>
</tr>
<tr>
<td><input name=\"jpg2\" type=\"file\"></td>
</tr>
<tr>
<td><input name=\"jpg3\" type=\"file\"></td>
</tr>
<tr>
<td>
<input type=\"hidden\" name=\"author\" value=\"".$_SESSION['login']."\"/>
<input type=\"submit\" name=\"go\" value=\"Odeslat\"/>
</td>
</tr>
</table>
</div>
</form>
zpracovávající script:<?php
if (isset($_POST['go'])) {
$text = stripslashes(htmlspecialchars(trim($_POST['editor1'])));
$author = $_POST['author'];
require_once "../include/db.php";
mysql_query("INSERT INTO `events` (`text`,`author`) VALUES ('$text','$author')");
$dotaz = mysql_query("SELECT * FROM `events` WHERE `text` = '$text' ORDER BY `id` DESC LIMIT 1");
while ($vypis = mysql_fetch_array($dotaz)) {
$id = $vypis['id'];
}
$dir = "../img/".$id;
if (!file_exists($dir)) {
mkdir($dir, 0777);
} // po sem je to určitě dobře
$cesta = "../img/".$id;
//$povoleni = array('jpg', 'jpeg', 'png', 'gif'); // nepotřebné
$jpg1 = ($_FILES['jpg1']['name']);
$jpg2 = ($_FILES['jpg2']['name']);
$jpg3 = ($_FILES['jpg3']['name']);
include "../include/prevodni-tabulka.php";
$jpg1 = strtr($jpg1, $prevodni_tabulka);
$jpg2 = strtr($jpg2, $prevodni_tabulka);
$jpg3 = strtr($jpg3, $prevodni_tabulka);
require_once "../include/db.php";
mysql_query("INSERT INTO `events` (`jpg1`,`jpg2``jpg3`) VALUES ('$jpg','$jpg2','$jpg3')");
if (move_uploaded_file($jpg1, $cesta)) {
}
if (move_uploaded_file($jpg2, $cesta)) {
}
if (move_uploaded_file($jpg3, $cesta)) {
}
header("Location: ".$_SERVER['SERVER_ROOT']."http://www.xxx.cz/akce.php");
}
header("Location: ".$_SERVER['SERVER_ROOT']."http://www.xxx.cz/akce.php");
?>
nebude chyba už v tom základu "<form method=\"POST\" action=\"scripty/akce.php\" enctype=\"multipart/form-data\">"? nebo kde mám chybu? složka se vytvoří, ale soubory se nevloží ani do složky a ani do databáze, proč?