So I have an html form and it is passing my picture(the actual name), but that is all I can get. It shows an error when I try to get the tmp_name or anything of that sort.
Also, I can only get the name of the file if my html form has no declared enctype
.
HTML
<form action="{{ urlFor('account.profile.post') }}" method="post" autocomplete="off">
<!-- OTHER TEXT INPUTS THAT OUTPUT PERFECTLY FINE -->
<div class="form-group">
<label for="propic">Profile picture</label>
<input type="file" id="propic" name="propic">
</div>
</form>
PHP
if($app->request->params('propic') != null) {
$propic = $app->request->post('propic');
$target_dir = "profs/$img_salt/";
$target_file = $target_dir.$propic;
$uploadOk = 1;
$imageFileType = pathinfo($target_file, PATHINFO_EXTENSION);
if (move_uploaded_file($propic["tmp_name"], $target_file)) {
echo "The file ". basename( $propic["name"]). " has been uploaded.";
} else {
echo "Sorry, there was an error uploading your file.";
}
}