I am trying to upload an image and move to a folder in my root directory, but nothing is happening. When I tried to make the directory from php itself, the folder wasn't created either. Now I made the folder and tried to upload but still nothing happens. I have another website which in which it creates a folder and uploads an image to it and that works fine. I tried copying the exact code from that and using it, but still nothing happens. (I am still learning and I am running this on WAMP server on Windows)
Here is the HTML
<form method="post" action="?pg=editmovie&act=1" enctype="multipart/form-data">
<p class="formtext" id="topttx"> Film title </p>
<input type="text" name="title" id="topbox">
<p class="formtext" id="sttx">Director </p>
<input type="text" name="dir" id="sbox">
<p class="formtext" id="sttx">Actor 1 </p>
<input type="text" name="act1" id="actbox">
<p class="formtext" id="sttx">Actor 2 </p>
<input type="text" name="act2" id="actbox">
<p class="formtext" id="sttx">Actor 3 </p>
<input type="text" name="act3" id="actbox">
<p class="formtext" id="sttx">Genre </p>
<input type="text" name="gre" id="grbox">
<p class="formtext" id="yrtxt">Year </p>
<input type="text" name="yr" id="yrbox">
<p class="formtext" id="sttx">Film cover </p>
<input type="file" name="img">
<input type="submit" value="Add Film" name="sub">
</form>
and the PHP
function act1()
{
if(isset($_POST['sub']))
{
$tle = $_POST['title'];
$dir = $_POST['dir'];
$a1 = $_POST['act1'];
$a2 = $_POST['act2'];
$a3 = $_POST['act3'];
$gre = $_POST['gre'];
$yr = $_POST['yr'];
$conn = getDBConn();
$sql = "INSERT INTO movies(title, director, act_1, act_2, act_3, genre, year) VALUES('$tle','$dir','$a1','$a2','$a3','$gre','$yr')";
$output = mysqli_query($conn,$sql);
$dir = "images/films/";
$imno = mysqli_insert_id($conn);
$src = $_FILES['img']['tmp_name'];
$des = $dir.$imno;
move_uploaded_file($src,$des);
}
if($output==1)
{
echo 'Data Stored';
}
else
{
echo 'Data Not Stored ';
echo mysqli_error($conn);
}
}
?>
**********Sorry guys, it is working properly, I have given the linked a different page in my form action so that's why it wasn't working