Hi,
I build form to upload photo
how can I see the photo on the form after i uploaded it?
Thanks
I build form to upload photo
how can I see the photo on the form after i uploaded it?
Thanks
<?php
/* ensure that this file is called by another file */
defined('_JEXEC') or die('Restricted access');
?>
<h3>Upload results</h2>
<?php
$MyUploads =& CFUploads::getInstance($MyForm->formrow->id);
$file_path_1 = $MyUploads->attachments['file_1'];
$file_path_2 = $MyUploads->attachments['file_2'];
if ( $file_path_1 ) {
// this is a document
$file_url = substr($file_path_1, strlen(JPATH_SITE)+1);
$file_url = str_replace(DS, '/', $file_url);
$file_url = JURI::base().$file_url;
$caption = JRequest::getString('file_desc_1', 'this file', 'post');
echo "<div style='font-weight:bold;'>Your file has been uploaded</div>";
echo "<div>Copy the following code to paste into the Forum<br />";
echo "".$caption."</div>";
echo "<div>The file URL is:<br />";
echo "$file_url</div>";
} elseif ( $file_path_2 ) {
// this is an image
$file_url = substr($file_path_2, strlen(JPATH_SITE)+1);
$file_url = str_replace(DS, '/', $file_url);
$file_url = JURI::base().$file_url;
jimport('joomla.filesystem.file');
$file['name'] = JFile::getName($file_path_2);
$file['ext'] = JFile::getExt($file['name']);
$file['root'] = JFile::stripExt($file['name']);
$file['small'] = $file['root'].'_small.'.$file['ext'];
$file['large'] = $file['root'].'_large.'.$file['ext'];
$file['url'] = substr($file_url, 0, -strlen($file['name']));
$file['img_url'] = str_replace('upload_1', 'images', $file['url']);
$size = getimagesize($file_path_2);
$caption = JRequest::getString('file_desc_1', 'this file', 'post');
$doc =& JFactory::getDocument();
$doc->addStyleDeclaration('div.img_link{
font-family:consolas,\"Andale Mono\",courier, monospace;
padding:6px;
border:1px solid silver;
color:blue;}');
echo "<div style='font-weight:bold;'>Your image has been uploaded.</div>
<div>Here's a thumbnail:</div>";
echo "<div style='padding:6px 0;' ><img src='".$file['img_url'].$file['small']."' /></div>";
echo "<div>Copy the following code to paste into the Forum<br />";
if ( $size[0] <= 600 && $size[1] <= 600 ) {
// use original image
echo "<div>Use this code to put the image in a Forum post:</div>";
echo "<div class='img_link' >
<br />".$caption."</div>";
} else {
// use re-sized image
echo "<div>Use this code to put 600px version image in a Forum post linked to the full-size image:</div>";
echo "<div class='img_link' >
<br />".$caption."</div>";
}
echo "<div>Use this code to put a thumbnail in a Cave post linked to the full-sized image:</div>";
echo "<div class='img_link' >
<br />".$caption."</div>";
echo "<div>The original image URL is:</div>";
echo "<div class='img_link' >$file_url</div>";
} else {
echo "Sorry, there seems to have been a problem";
}
?>
<div style='padding-top:6px;'>
<a href='<?php echo JURI::base().'index.php?option=com_chronocontact&chronoformname=upload_1'; ?>'>
<input type='button' name='upload' value='Upload another file?' /></a>
</div>