2017-03-07 11 views
0

Ich erhalte diesen Fehler, wenn ich meinen Bilduploadcode einfüge. Alles funktioniert ohne es. Ich habe das viele Male neu geschrieben und suche hoch und tief aber ich bekomme trotzdem: Hinweis: Undefinierter Index: file_img in C: \ wamp \ www \ HW2_Submissions \ movieSub.php in Zeile 12 Wenn ich die beiden in eigene Bilder zerlege, und Creammovie-Stücke funktionieren sie gut alleine. Das Snippet, das ich Ihnen gegeben habe, ist der Body-Bereich des HTML, es gibt eine Menü-, Kopf-, Verbindungs- und Fußzeilen-PHP-Datei, die getrennt ist, und die Verbindung beherbergt die DB-Information. Bitte helfen Sie, danke.Nicht identifizierter Indexfehler PHP

<?php 



if (isset($_POST['add'])) { 

$name = $_POST['name']; 
$email = $_POST['email']; 
$movie = $_POST['movie']; 
$director = $_POST['director']; 
$lead = $_POST['lead']; 
$textArea = $_POST['textArea']; 

$filetmp = $_FILES["file_img"]["tmp_name"]; 
$filename = $_FILES["file_img"]["name"]; 
$filetype = $_FILES["file_img"]["type"]; 
$filepath = "images/".$filename; 

$query = "INSERT INTO createmovie (movieID, userName, email, movieName, directorsName, lead, Info) VALUES 
    (NULL,'$name', '$email', '$movie', '$director', '$lead','$textArea'); INSERT INTO images (imageID, img_name, img_path, img_type) VALUES (NULL, '$filename','$filetype','$filepath')"; 
    mysqli_multi_query($conn, $query); 



//  $result = $conn->query($query); 
// if (!$result) die($conn->error); 

if (headers_sent()) { 
    die("Redirect failed. Please click on this link: <a href='movies-list.php'>Movie List</a>"); 
}else{ 
    exit(header("Location: movies-lists.php")); 
} 
?> 

<div class="clearfix colelem" id="u711-4"><!-- content --> 
    <p>Welcome Please Submit Movie</p> 
    </div> 

<form action="movie-add.php" method="post" style="padding-top: 220px"> 
    <div class="form-group" > 
    <label for="InputName1">Your Name</label> 
    <input type="name" name="name" class="form-control" id="InputName1" aria-describedby="nameHelp" placeholder="Enter Name"> 
    <small id="nameHelp" class="form-text text-muted">We'll never share your information with anyone else.</small> 
    </div> 
    <div class="form-group"> 
    <label for="Inputemail1">Email</label> 
    <input type="email" name="email" class="form-control" id="Inputemail1" placeholder="Email"> 
    </div> 
    <div class="form-group" > 
    <label for="InputMovie1">Movie Name</label> 
    <input type="text" name="movie" class="form-control" id="InputMovie1" aria-describedby="movieHelp" placeholder="Movie Name"> 
    </div> 
    <div class="form-group" > 
    <label for="InputDirector1">Directors Name</label> 
    <input type="text" name="director" class="form-control" id="InputDirector1" aria-describedby="directorHelp" placeholder="Director Name"> 
    </div> 
    <div class="form-group" > 
    <label for="InputLead1">Lead Actor/Actress</label> 
    <input type="text" name="lead" class="form-control" id="InputLead1" aria-describedby="LeadHelp" placeholder="Lead Name"> 
    </div> 
    <div class="form-group"> 
    <label for="Textarea">More Information</label> 
    <textarea class="form-control" id="Textarea" name="textArea" rows="3"></textarea> 
    </div> 
    <div class="form-group"> 
     <input type="file" name="file_img" /> 
    </div> 
    <button type="submit" name="add" class="btn btn-primary" >Submit</button> 
</form> 

Antwort

1

Sie benötigen enctype='multipart/form-data' Datei hochladen:

<form action="movie-add.php" enctype="multipart/form-data" method="post" style="padding-top: 220px"> 
+0

@Daominhat dank ich es begrüßen, ich schwöre, dass ich vor diesem ausprobiert. Aber egal, es funktioniert jetzt. Vielen Dank – Rico

Verwandte Themen