View Single Post
Old 03-28-2005, 12:45 PM   #8 (permalink)
DJMaze
Senior Contributor
 
DJMaze's Avatar
 
Join Date: Mar 2005
Posts: 660
DJMaze is on a distinguished road
Quote:
Originally Posted by chrislopezz
Now one of the feature i want to have in this form is a File Attachments Feature where-in users can attach a file to the Task/Email and submit the attached file-names to the DB. Ive taken care of the DB submission, File Upload part but came to an obstace where-in -- when the user is entering data into the main form, he should be able to click an "Attach File" button which opens up a File Upload feature where-in he uploads his File Attachments and those file names are passed into a textbox of the Main form (preceding form). Basically this is a Passing Values from Popup Window to Main Window scenario.
Everyone talked about a "1 step" popup where the onsubmit="send(this);" sends the data to the main window.

However with file uploads it doesn't work that way.
The popup should verify the upload and on success it should return a page which contains javascript that gets executed immediatly to the 'opener'

PHP Code:
<html><head><title>File upload</title>
<php
if (isset($_FILES['upload'])) {
  // do upload checking and the uploaded file
?>
<script language="javascript" type="text/javascript"><!--
opener.document.forms['f'].elements['file_path'].value = '<?php echo $file_name?>';
//--></script>
</head>
<body>
File upload succeeded<br />
The file is stored at http://something.com/<?php echo $file_name?>
<?php
} else {
  
// show file upload form
?>
</head>
<body>
<form>bla di bla</form>
<?php
}
?>
</body></html>
DJMaze is offline   Reply With Quote