Witam
Mam problem z wrzuceniem pliku na mojej stronie. Podczas wykonywania skryptu wyskakuje mi błąd "Undefined index: image" w linijce z $_FILES. Przeglądałem już masę stron i nie mam pojęcia co jest nie tak :( mam nadzieje że pomożecie.
if(isset($_POST['submit_post'])){
$title = strip_tags($_POST['title']);
$date = date('Y-m-d h:i:s');
if($_FILES['image']['name']){
$image_name = $_FILES['image']['name'];
$image_tmp = $_FILES['image']['tmp_name'];
$image_size = $_FILES['image']['size'];
$image_ext = pathinfo($image_name,PATHINFO_EXTENSION);
$image_path = '../images/'.$image_name;
$image_db_path = 'images/'.$image_name;
if($image_size < 1000000){
if($image_ext == 'jpg' || $image_ext == 'png' || $image_ext == 'gif'){
if(move_uploaded_file($image_tmp, $image_path)){
$ins_sql = "INSERT INTO posts (title, description, image, category, status, date, author) VALUES ('$title', '$_POST[description]', '$image_db_path', '$_POST[category]', '$date', '$_SESSION[user]')";
if(mysqli_query($conn, $ins_sql)){
header('post_list.php');
} else{
$error = '<div class="alert alert-danger">The Query Was Not Working!</div>';
}
} else {
$error = '<div class="alert alert-danger">Sorry, Unfortunately Image host not been uploaded!</div>';
}
} else{
$error = '<div class="alert alert-danger">Image Format was not Correct!</div>';
}
} else{
$error = '<div class="alert alert-danger">Image File Size is much bigger then Expect!</div>';
}
} else {
$ins_sql = "INSERT INTO posts (title, description, category, status, date, author) VALUES ('$title', '$_POST[description]', '$_POST[category]', '$_POST[status]', '$date', '$_SESSION[user]')";
if(mysqli_query($conn, $ins_sql)){
header('post_list.php');
} else{
$error = '<div class="alert alert-danger">The Query Was Not Working!</div>';
}
}
}
a to mój formularz :
<div class="form-group">
<label for="image">Upload an Image</label>
<input id="image" type="file" name="image" class="btn btn-primary">
</div>