+ 1

keep having this error undefined error: file ......

<?php if(isset($_POST['submit1'])) { $tm = md5 (time()); $fnm = $_FILES["file"]["name"]; $dst = "../LMS for OCC/librarian/books_images/".$tm.$fnm; $dst1 = "books_images/".$tm.$fnm; move_uploaded_file($_FILES["file"]["tmp_name"],$dst); mysqli_query($conn,"insert into add_book values('','$_POST[bname]','$dst','$_POST[aname]','$_POST[pname]','$_POST[pdate]','$_POST[price]','$_POST[qty]','$_POST[aqty]','$_SESSION[librarian]')"); ?> <script type="text/javascript"> alert("books insert successfully"); </script> <?php } ?>

23rd Aug 2018, 3:24 AM
Phoebe Gaufo
Phoebe Gaufo - avatar
2 Réponses
+ 2
Your code tried to refer to an element that doesn't exist in $_FILES array, I don't know which line because your error message didn't clearly specify it. (Edit) I think it's in the line where you move uploaded file. Dump $_FILES as follows to see what keys and values it contain, and see which one you actually want. var_dump($_FILES); Hth, cmiiw
27th Aug 2018, 2:39 AM
Ipang
0
notice : undefined index : file in
27th Aug 2018, 1:58 AM
Phoebe Gaufo
Phoebe Gaufo - avatar