The testing code below produces:
Code: Select all
file count=0 array(0) { }
Code: Select all
<form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-freebie">
<div class="form-group">
<label for="pdftitle">PDF Title</label>
<input type="text" class="form-control" id="pdftitle" name="pdftitle" placeholder="Title of PDF Goes Here">
</div>
<div class="form-group">
<label for="pdftitle">PDF Upload</label>
<input type="file" id="pdfupload" name="pdfupload">
</div>
<button type="submit" class="btn btn-primary pull-right">Submit</button>
</form>
Code: Select all
if (($this->request->server['REQUEST_METHOD'] == 'POST')) {
$this->model_extension_feed_freebies->add($this->request->post);
$directory = DIR_IMAGE . 'downloads';
$filename = basename(html_entity_decode($this->request->post['pdftitle'], ENT_QUOTES, 'UTF-8'));
echo 'file count=', count($_FILES),"\n";
var_dump($_FILES);
exit();
if (move_uploaded_file($_FILES["pdfupload"]["tmp_name"], $directory . '/' . $filename . '.pdf')) {
echo "The file has been uploaded.";
exit();
} else {
echo "Sorry, there was an error uploading your file.";
exit();
}