Forums

File is uploaded but file path is not saved in table

whiteangel 09 Jan, 2011
Hi,
I am working on a multiform with a file upload option. The multiform works correctly. The problem is that all the fields in the multiform get saved to the database except for the file upload paths. The file upload fields remain blank. But the files themselves are uploaded successfully.

Can someone please help he with this.

Thanks
GreyHead 09 Jan, 2011
Hi whiteangel,

I just ran a test and the file name (but not the path) is saved OK for me.

Update: it saves OK if the file upload is on the last step but not if it's on the last but one.

Is the DB Connection on the mother form? Which step is the file upload on?

Bob
GreyHead 09 Jan, 2011
Hi whiteangle,

Here's a workaround hack.

please edit the file components/com_chronocontact/plugins/cf_multi_page.php, look for this code block around line 217 and insert the three lines shown.
        $oldposted = array();
        if ( $session->get('chrono_formpages_data_'.$formname, array(), md5('chrono')) ) {
            $oldposted = $session->get('chrono_formpages_data_'.$formname, array(), md5('chrono'));
        }
		if ( $session->get('chrono_formpages_files_'.$formname, array(), md5('chrono')) ) {
			$MyUploads->attachments = $session->get('chrono_formpages_files_'.$formname, array(), md5('chrono'));
		}
		// insert the following three lines
		if ( count($MyUploads->attachments) ) {
			$newposted = array_merge($newposted, $MyUploads->attachments);
		}
		// end insert	
        $posted = array_merge($oldposted, $newposted);
        $messages[] = 'Posted: '.print_r($posted, true);
		$messages[] = 'Files: '.print_r($MyUploads->attachments, true);

The effect of this is to add the file info to the post information carried forward by the plug-in to later steps. Note that this now saves the full file path rather than just the file name. If this is a problem let me know and we'll find a fix.

Bob
whiteangel 10 Jan, 2011
Hi,

Just to explain the issue a bit further...

I have a three page multipage form and the upload option is in the second form. The last page in the form basically confirms all the details you have entered previously and then saves everything when you hit confirm.

When the third form spits out the details of what you have entered previously, the file upload field stays empty but all the other data that you entered shows up fine.

I will try the fix you have suggested and let you know of the results.

Thanks
GreyHead 10 Jan, 2011
Hi whiteangel,

That's pretty much what I tested yesterday. Hopefully the fix will work for you.

Bob
whiteangel 10 Jan, 2011
Hi Bob,

Thanks for the fix; it worked perfectly. Now the database shows the file name along with the complete path.

Just one question though. In my three page multiform, the first two forms are used for entering information while the third form shows you the information you have entered in the previous forms and is used to confirm and save what you have entered previously. All the other fields show up in the third form, except for the names of files that you are uploading.

Is there a way to show names of files that are being uploaded on the third form, before you actually confirm and save the form details.

To call up the file upload entry , the PHP code that I am using in the third form's html is as follows:

  <?php
   if (isset($posted['reg_file_upload']))
   {
     $field15=$posted['reg_file_upload'];
   }else{
     $field15='';
   }
   echo 'File uploaded: '.$field15.'<br/>';
   ?>


Thanks
GreyHead 10 Jan, 2011
Hi whiteangel,

After the code hack the file path is being added to the $posted array and I think that this code should work (assuming that reg_file_upload is the name of the file input).

Is it still not working?

Can you try print_r($posted) to what is in the array (or turn on the plug-in debug).

Bob
whiteangel 10 Jan, 2011
Hi Bob,

Thanks I really appreciate your help

I have two file upload boxes in my second form. In the third and final confirmation form, only the first file that was selected by the user is shown along with the path that it will be be saved in, but the file from the second upload box does not appear in the confirmation form.

However, in the tables, both files are appearing with complete path and both are being uploaded into the directory.
GreyHead 11 Jan, 2011
Hi whiteangel,

If the file uploads are on different steps please check that the file inputs have different names. If they both have the same name e.g. file_0 then the both will be uploaded OK buT the second will over-write the first in the results array.

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