• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: View instead of download the file submitted

View instead of download the file submitted 12 years 1 month ago #16798

  • eejoes
  • eejoes's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 1
Hi,

I'm just trying to make a list of submission which is available through rsjoomla pro list module. Yet there is one problem for me: I need to display image of which previously submitted through file upload function. Simply: when I click the file image name displayed, I want to display it with a light box instead of download it.

Where or how should I make this thing possible?
The administrator has disabled public write access.

Re: View instead of download the file submitted 11 years 10 months ago #17892

  • robert49
  • robert49's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 4
  • Thank you received: 1
It's possible to show an image after upload. but it's not easy, because it is not a standard functionality in RSForms. You need to create a new form, in this new form you need to add some custom html in a free text box.

for example:
<img src="image.php" />

its possible to wrap this into the lightbox code.

In the image.php you need to use an SQL SELECT statement to fetch the submitted row. After you fetched the submitted row you are able to select the file, the filename code needs to be processed and checked on extension type. after that you are able to use the GD PHP library to render the image back into your lightbox. You need to have the GD library enabled in the PHP.ini or by your hosting provider if it isn't enabled. this way you are also able to perform transformations onto the image such as scaling or drawing lines etc. I use this way to render a rendered page for printing several images at once.

a little example:
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
 
if (file_exists(dirname(__FILE__) . '/defines.php')) {
	include_once dirname(__FILE__) . '/defines.php';
}
 
if (!defined('_JDEFINES')) {
	define('JPATH_BASE', dirname(__FILE__));
	require_once JPATH_BASE.'/includes/defines.php';
}
 
require_once JPATH_BASE.'/includes/framework.php';
 
$mainframe = &JFactory::getApplication('site');
 
$imageRecId = $mainframe->getUserState('<imageRecord>');
 
$db =& JFactory::getDBO();
 
if($imageRecId ){
	$db->setQuery("SELECT file1 FROM #__<ADATABASETABLE> WHERE id='".$imageRecId."';");
}
 
$result = $db->loadObjectlist();
 
$file = "<somepathtoFile>".getFileName($result[0]->file1);
 
 
function getFileName($file){
	// performing regex
	$do = preg_match("/>(.*)<\/a>/", $file, $matches);
	// Check if regex was successful
	if ($do = true) {
	// Matched something, show the matched string
	// echo htmlentities($matches['0']);
	// Also how the text in between the tags
	// echo '<br />' . $matches['1'];
	$file=$matches['1'];
	} else {
	// No Match
	// echo "Couldn't find a match";
	}
	return $file;
}
 
function getFileName($file){
	// performing regex
	$do = preg_match("/>(.*)<\/a>/", $file, $matches);
	// Check if regex was successful
	if ($do = true) {
	// Matched something, show the matched string
	// echo htmlentities($matches['0']);
	// Also how the text in between the tags
	// echo '<br />' . $matches['1'];
	$file=$matches['1'];
	} else {
	// No Match
	// echo "Couldn't find a match";
	}
	return $file;
}
 
header('Content-Type: image/png');
$im = ImageCreateTrueColor($width,$height);
$im = imageArray($im);
imagepng($im);
imagedestroy($im);
 
function imageArray($im,$imgUrl,$imgType){
 
	if($imgType == "bmp"){
		$image = imagecreatefromwbmp($imgUrl);
	}
	if($imgType == "gif"){
		$image = imagecreatefromgif($imgUrl);
	}
	if($imgType == "png"){
		$image = imagecreatefrompng($imgUrl);
	}
	if(($imgType == "jpg") || ($imgType == "jpeg")){
		$image = imagecreatefromjpeg($imgUrl);
	}
 
	$imageSize = getimagesize($imgUrl);
 
	$imageWidth = $imageSize[0];
	$imageHeight = $imageSize[1];
        $sizeWidth = $imageSize[0]; //possibility to scale image down.
        $sizeHeight = $imageSize[1]; //possibility to scale image down.
        $xcoor = 0; 
        ycoor = 0;
 
	imagecopyresampled($im, $image,$xcoor, $ycoor, 0, 0,$sizeWidth,$sizeHeight,$imageWidth,$imageHeight);
	return $im;
}
ImageAntiAlias($im, true);
 

You need to place the php code in a file named image.php. This file needs to be uploaded to the joomla site. in my example it must be placed on the root.
Last Edit: 11 years 10 months ago by robert49.
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!