Your IP : 216.73.216.240


Current Path : /home/juvelize/saulnois/tmp/install_695d2cf0b4957/src/Field/
Upload File :
Current File : /home/juvelize/saulnois/tmp/install_695d2cf0b4957/src/Field/UploadField.php

<?php
/*
* @package		Tech Fry Library
* @license		https://www.gnu.org/licenses/gpl-3.0.en.html
*/

namespace TechFry\Library\Field;

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Form\Field\FileField;

class UploadField extends FileField
{
	protected $type = 'Upload';

    protected function getInput()
    {
        $input = parent::getInput();

        $value = '';
      	if (!empty($this->value) && \is_string($this->value))
        {
        	$value = htmlspecialchars($this->value, ENT_QUOTES);
        }

        if ($value && file_exists(JPATH_ROOT . '/' . $value))
        {
            $uri = new Uri();
            
            $a = '<a href="' . $uri->root() . $value . '" target="_blank">View Uploaded File</a>';
            $input = '<div>' . $a . '</div>' . $input;
        }
        

        /*
      	if (!empty($this->value))
        {
        	// For multiple files, $this->value is csv
			if (\is_string($this->value))
			{
				$files = str_getcsv($this->value);
			}
			elseif (\is_array($this->value))
			{
				$files = $this->value;
			}
			
			foreach ($files as $file)
			{
				if (file_exists(JPATH_SITE . '/' . $file))
				{
					$input .= '<strong><a href="/' . $file . '" target="_blank">View Uploaded File</a></strong><br>';
				}
				else
				{
					$input .= 'File Not Found<br>';
				}
			}
        }
    */
      	return $input;
    }
}