see upload photo

confis 04 Apr, 2009
I build form to upload photo
how can I see the photo on the form after i uploaded it?

Max_admin 06 Apr, 2009
Hi Confis,

where in the form ? what do you want to display exactly after the form is submitted ? show a list of files or only that file which have just been uploaded ? give me more details plz!

ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
Winchester 29 Mar, 2010
Hi, I am also building a form registrants to use to upload photos and add a caption for each photo. It would be great if the uploader can see a preview of the photos they uploaded with the captions on the confirmation page.

Is there a way to do this? And there is, how can I do it?

I notice that there's a plugin for resizing photos. So, I figure that there must be a way to preview as I described.

Thanks in advance.

Winchester 29 Mar, 2010
I should also add that I'm giving the uploader the option to upload a compressed archive (ie. zip, rar, ace, sit, etc.)

I'm setting you 10 upload fields with a textbox field below each one for he captions. Only the first upload field will be able to be used for archived files and photo files (with a 8mb file size limit). All the others are photos only (with 200kb limits).

This way, they don't try to upload more than one file as large as 8mb. And even if they upload an 8MB file and 200kb photo files in all the rest, it won't exceed the 10mb limit that my email server can accommodate.
GreyHead 30 Mar, 2010
Hi Winchester,

it is certainly possible to use the info from the uploaded files to create <img> tags in the OnSubmit After box and display the images there. Here is an example I wrote for something similar. In this case there are two file uploads, one for docs and one for images, the image one uses the resier to create a thumbnail and show that together with bbcode for posting into a forum with a link the the larger copies.
/* ensure that this file is called by another file */
defined('_JEXEC') or die('Restricted access');

<h3>Upload results</h2>
$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;

    $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();
    font-family:consolas,\"Andale Mono\",courier, monospace;
    border:1px solid silver;
    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>

This topic is locked and no more replies can be posted.