Source for file formpopup.php
Documentation is available at formpopup.php
@include '../include_path.php';
* A form is used to select and submit any kind of file to webserver
* while a progress meter is running in indeterminate mode inside a popup.
* @version $Id: formpopup.php,v 1.2 2004/07/02 17:49:06 farell Exp $
* @author Laurent Laville <pear@laurent-laville.org>
require_once 'HTML/QuickForm.php';
$destination = './uploads/';
$file = & $form->getElement ('tstUpload');
if ($file->isUploadedFile ()) {
$ok = $file->moveUploadedFile ($destination);
// write the semaphore to tell progress meter to stop
// in script 'progressbar.php'
$fp = fopen($destination . $_GET['ID'],'w',false );
<script language="javascript">
theFeats = "height=100,width=250,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no";
theUniqueID = (new Date()).getTime() % 1000000000;
window.open("progressbar.php?ID=" + theUniqueID, theUniqueID, theFeats);
document.formpopup.action = "formpopup.php?ID=" + theUniqueID;
document.formpopup.submit();
$form = & new HTML_QuickForm ('formpopup');
// We need an additional label below the element
$renderer = & $form->defaultRenderer ();
$renderer->setElementTemplate (<<<EOT
<td align="right" valign="top" nowrap="nowrap"><!-- BEGIN required --><span style="color: #ff0000">*</span><!-- END required --><b>{label}</b></td>
<td valign="top" align="left">
<!-- BEGIN error --><span style="color: #ff0000">{error}</span><br /><!-- END error -->{element}
<!-- BEGIN label_2 --><br/><span style="font-size: 80%">{label_2}</span><!-- END label_2 -->
$form->addElement ('header', null , 'Uploaded file rules');
$form->addElement ('file', 'tstUpload', array ('Upload file:', 'Rule types: \'uploadedfile\', \'maxfilesize\' with $format = 10240, \'mimetype\' with $format = \'text/xml\', filename with $format = \'/\\.xml$/\'<br />Validation for files is obviuosly <b>server-side only</b>'));
$form->addRule ('tstUpload', 'Upload is required', 'uploadedfile');
$form->addRule ('tstUpload', 'File size should be less than 10kb', 'maxfilesize', 10240 );
$form->addRule ('tstUpload', 'File type should be text/xml', 'mimetype', 'text/xml');
$form->addRule ('tstUpload', 'File name should be *.xml', 'filename', '/\\.xml$/');
$form->addElement ('header', null , 'Submit the form');
$submit[] = & $form->createElement ('button', null , 'Upload', array ('onClick'=> 'DoUpload();'));
$form->addGroup ($submit, null , null , ' ', false );
$form->applyFilter ('__ALL__', 'trim');
// Form is validated, then processes the data
$form->process ('myProcess', true );
echo '<p><< <a target="_top" href="../index.html">Back examples TOC</a></p>';
} elseif (isset ($_GET['ID'])) {
$destination = './uploads/';
$fp = fopen($destination . $_GET['ID'],'w',false );
Documentation generated on Mon, 11 Mar 2019 13:52:37 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|