I have been trying to find a thread that could help, and have tried everything I could find to fix this.
I have a page that uploads a file, can be any type, and it works. I decided to use that same functionality on another page, but the $_FILES array is always empty.
Form:
<form method="post" class="mainForm" enctype="multipart/form-data">
<fieldset>
<div class="widget first">
<div class="rowElem">
<label for="file">Upload Profile Picture</label>
<div class="formRight">
<input type="file" id="profilepicture" name="profilepicture" />
<button formaction="profile_pic.php" class="greyishBtn">Upload</button>
</div>
</div>
</fieldset>
</form>
PHP:
$name_first = "John";
$name_last = "Doe";
$folder_name = $name_last . "-" . $name_first . "-ID-" . $id . "/";
$dirname = "profile/" . $folder_name;
if(!is_dir($dirname)){
mkdir($dirname);
}
$dirname = $dirname . $_FILES['file']['name'];
if(move_uploaded_file($_FILES['file']['tmp_name'], $dirname)){
header("location:profile.php");
}
else{
echo $dirname;
}
?>
The echo $dirname
just shows the folder with no file name.