I'm making a function to insert some items to my database table but the images have to be saved locally to once uploaded. When I try doing that it keeps getting the error that it's not possible to upload it. Why's that?
<?php
if (isset($_GET['action']) and $_GET['action'] == 'add') { ?>
<div>
<form method='post' action='upload.php?action=add'>
<h2>Add new songs</h2>
<input type="hidden" name="action" value="insert">
<input type='text' name='title' class='textInput' placeholder='song title'>
<input type='text' name='composer' class='textInput' placeholder='composer'>
<input type='text' name='genre' class='textInput' placeholder='genre'>
<input type='text' name='instrument1' class='textInput' placeholder='instrument1'>
<input type='text' name='instrument2' class='textInput' placeholder='instrument2'>
<input type='text' name='instrument3' class='textInput' placeholder='instrument3'>
<input type='text' name='instrument4' class='textInput' placeholder='instrument4'>
<input type='text' name='instrument5' class='textInput' placeholder='instrument5'>
<div>
<label for="pngSheet">Image PNG file</label>
<input type="file" name='pngSheet' accept='.png'>
</div>
<div>
<label for="xmlSheet">Music XML file</label>
<input type="file" name='xmlSheet' accept='.musicxml'>
</div>
<input type='submit' name='submit' value='Add'>
</form>
</div>
<?php }
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($_POST['action'] == 'insert') {
$getTitle = $_POST['title'];
$getComposer = $_POST['composer'];
$getGenre = $_POST['genre'];
$getImgSheet = $_POST['pngSheet'];
$getSheet = $_POST['xmlSheet'];
$location = '../img/' . $getImgSheet;
if (move_uploaded_file($_POST['pngSheet'], $location)) {
$query = "INSERT INTO `imslp_sheets`(`sheets_title`, `sheets_composer`, `sheets_genre`, `sheets_img`,`sheets_xml`) VALUES ('$getTitle', '$getComposer', '$getGenre', '$getImgSheet','$getSheet')";
$result = $conn->query($query);
} else {
echo "Error uploading file $getImgSheet";
}
}
}
?>