Forums

Problem with file upload in multipage form.

kuti 16 Sep, 2011
Hi chronoform fellows,

Firstly, thank Max very much for the wonderful form, this product is definitely is the best form for Joomla.

Secondly, I also would like to say thank to GreyHead for your incredible support us, and your book is really helpful for me (I got both paper and pdf version).

Thought this is a my first post in here as I am really hard working to trying solve my own problem as well as searching in the forum to get the solution.

Till now, the form which I currently working on is almost done but I just met a very strange problem which is:

After I submitted the form (to create a record 1), I received an email include attachment, the form data and a link to download the file attached (chronoform book chapter eight page 205). And the form also insert record 1 data into table which including the file’s upload path.

Everything is working very nicely except if I immediately open that form again to create a new record (record 2). When I submit the form, it only remembered the name and the path of the record 1 file.

Another odd thing is no attachment in the email of the record 2, but it still showed the link to download it, when I click to that link and it download the file of record 1.

If I clear the browser’s cache or using different browser to make a new record, it happen exactly the same as the first record is created nicely but the second one is also remember the first one file.

Definitely is something gone wrong but I am struggling to find the solution for this matter, please help me!!!

The details of my current form are:
- Chronoform V3.2 (already path the chronoformuploads.php, special thanks to GreyHead about this)
- Chronoconectivity V2 RC3
- The form is multipage form with 4 steps, a confirmation page and a mother form. The file upload option is at the step 4.

Table data is display on the website’s front-end via connectivity plugin and it is able to delete, edit (using profile plugin) and create new record on the front-end when user log-in.

The form’s data is inserted into the database after the email has been sent.


Debug: Before submit


Debug: After submit

PS. I am really sorry if my writing is not clear, and please let me know if you need more details.
GreyHead 17 Sep, 2011
Hi Kuti,

The id strings that ChronoForms creates when the from is loaded appear to be the same in both cases. These should be different - that suggests to me that the form is being cached somewhere and not re-loaded cleanly. Is that possible?

Bob
kuti 17 Sep, 2011

Hi Kuti,

The id strings that ChronoForms creates when the from is loaded appear to be the same in both cases. These should be different - that suggests to me that the form is being cached somewhere and not re-loaded cleanly. Is that possible?

Bob



Hi Bob,

Thank you very much for your respond.

And yes, you are exactly right. I think the mother form was still keep the file array until the browser's cache has been removed. Is that possible to insert the php code somewhere in the mother form to clear the array after the form was submitted, Bob?

Many thanks!

kuti
GreyHead 17 Sep, 2011
Hi kuti,

Ah, that makes sense. Please try this at the start of the Form HTML:
<?php
$formname = 'my_form_name';
$session =& JFactory::getSession();
if ( $session->has('chrono_formpages_data_'.$formname, md5('chrono')) ) {
  $session->clear('chrono_formpages_data_'.$formname, md5('chrono'));
}
?>
Replace my_form_name in the second line with the name of your form.

Not tested and may well need debugging!

Bob
kuti 17 Sep, 2011
Hi Bob,

It is Saturday night now and you still here to help me. I really do appreciate it.

About your code: I did apply it in the html tag of the mother form and the problem is still occur.

I also tried to insert it in to "On Submit code - after sending email" tag of mother form as well as to the top of html tag in form 4 which containing the file upload field and the odd thing is still there.

Please have a look at debugs on each step:



**************************************************************************************************************

* File upload start showing at step 2



**************************************************************************************************************



**************************************************************************************************************



**************************************************************************************************************



**************************************************************************************************************

This is screen shot of file upload part which showing on confirmation page.



**************************************************************************************************************



**************************************************************************************************************

This is screen shot of file upload part which showing on email.



Again, please help me.

Kind regards,

Phan
GreyHead 18 Sep, 2011
Hi Phan,

I'm not quite sure what the problem is. The code to clear the session probably needs to go in the Form HTML of Step 1 (the Mother Form HTML isn't used).

Bob
kuti 19 Sep, 2011
Hi Bob,

Sorry for the late reply as I just came home from long and tired journey.

As you can see at the step 2 in the provided image, the file has been uploaded but the file upload option is in the step 4 which mean the form was automatically loaded the old upload file into the new form.

When I inserted your code into form 1, it is clear only the data in the text field, text area and other fields in all 4 forms except the file upload.

Is there any particular code to clear the old file upload, Bob?

Best regards.

Phan
GreyHead 19 Sep, 2011
Hi Kuti,

Ah, OK - there's slightly different code needed for the file data:
<?php
$formname = 'my_form_name';
$session =& JFactory::getSession();
if ( $session->has('chrono_formpages_data_'.$formname, md5('chrono')) ) {
  $session->clear('chrono_formpages_data_'.$formname, md5('chrono'));
}
if ( $session->has('chrono_formpages_files_'.$formname, md5('chrono')) ) {
  $session->clear('chrono_formpages_files_'.$formname, md5('chrono'));
}
?>

Bob
kuti 19 Sep, 2011
Hi Bob,

Your new wonderful code is come straight to the point. My problem was fixed now.

I just slightly change a bit which inserted the above code in “On Submit code - after sending email” tag at the mother form because all forms and confirmation page have a back button so it will clear all entered data when user go back to previous step.

Again, thank you very much for your help.

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