Example #1
0
<?php

require_once "../../../../dbConfig.php";
require_once "../../../../config.php";
$options = array('delete_type' => 'POST', 'db_host' => Config::dbServer(), 'db_user' => Config::dbUser(), 'db_pass' => Config::dbPassword(), 'db_name' => Config::dbName(), 'db_table' => Config::dbSurveyData() . '_files');
error_reporting(E_ALL | E_STRICT);
require 'UploadHandler.php';
class CustomUploadHandler extends UploadHandler
{
    protected function initialize()
    {
        $this->db = new mysqli($this->options['db_host'], $this->options['db_user'], $this->options['db_pass'], $this->options['db_name']);
        parent::initialize();
        $this->db->close();
    }
    protected function handle_form_data($file, $index)
    {
        $file->title = @$_REQUEST['title'][$index];
        $file->description = @$_REQUEST['description'][$index];
    }
    protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null, $content_range = null)
    {
        //    $file = parent::handle_file_upload($uploaded_file, $name, $size, $type, $error, $index, $content_range);
        $file = new \stdClass();
        $file->name = $name;
        $file->size = $size;
        //         $file->content = json_encode($uploaded_file);
        $file->content = str_replace(array('"', '\\'), "", $uploaded_file);
        if (file_exists($file->content)) {
            $test = file_get_contents($file->content);
            $file->description = strlen($test);