Exemplo n.º 1
0
 function ImageUpload()
 {
     ob_clean();
     $file = $_FILES['locationimage'];
     $dt_file = new DT_file();
     if ($dt_file->upload($file, 'locations')) {
         echo "DTjQuery('#image').val('" . $dt_file->path . "');\n";
         echo "DTjQuery('#showimag').html('<img src=\"index.php?option=com_dtregister&controller=file&w=" . $this->config->getGlobal('location_img_w', 120) . "&h=" . $this->config->getGlobal('location_img_h', 100) . "&task=thumb&no_html=1&filename=" . $dt_file->path . "\" />');\n";
         echo "alert('" . JText::_('DT_FILE_UPLOADED') . "');";
     } else {
         echo "alert('" . JText::_('DT_FILE_UPLOAD_ERROR') . "');";
     }
     die;
 }
Exemplo n.º 2
0
    function upload()
    {
        ob_clean();
        echo "<textarea>";
        $field_id = JRequest::getVar('field_id', '');
        $name = JRequest::getVar('name', '');
        $types = explode(",", JRequest::getVar('filetypes' . $name, ''));
        $file = $_FILES["file_" . $name];
        $size = JRequest::getVar('filesize' . $name, '');
        $newtype = array();
        if (is_array($types)) {
            foreach ($types as $type) {
                $newtype[] = "." . $type;
            }
        }
        if (is_array($newtype)) {
            foreach ($newtype as $val) {
                $types[] = $val;
            }
        }
        $dt_file = new DT_file();
        jimport('joomla.filesystem.file');
        $ext = JFile::getExt($file['name']);
        if ($file['name'] == "") {
            ?>
var data = {Error:'<?php 
            echo JText::_('DT_ERROR_FILE_NOT_FOUND');
            ?>
'}<?php 
            die;
        }
        if (in_array($ext, $types) || count($types) < 1) {
            if ($file['size'] / 1000 <= $size) {
                $folder = 'uploads';
                if (isset($_REQUEST['eventpic'])) {
                    $folder = "eventpics";
                }
                $dt_file->upload($file, $folder);
                $value = $dt_file->path;
                ?>
var data = {Error:'',path:'<?php 
                echo JFile::getName($dt_file->path);
                ?>
',message:'<?php 
                echo JText::_('DT_FILE_UPLOADED');
                ?>
'}	  <?php 
            } else {
                // file error
                ?>
var data = {Error:'<?php 
                echo JText::_('DT_ERROR_FILE_SIZE');
                ?>
'}<?php 
            }
        } else {
            // file type not valid
            ?>
         	var data ={Error:'<?php 
            echo JText::_('DT_ERROR_FILE_TYPE');
            ?>
'}
			<?php 
        }
        echo "</textarea>";
        exit;
    }