NetTalk Central

Author Topic: File Uploads - multiple  (Read 3823 times)

broche

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Email
File Uploads - multiple
« on: March 10, 2018, 12:38:22 AM »
Hi All,

CL 10
NT 10.18
STheory 2.73

Doing FIle Uploads and trying to
1) Save the uploaded file to another location
2) Create a record for each file attached to the parent by a staff ID

Works fine on single uploads
Works fine on multiples if I click start on each file
If I click start on multiple files
    - Saves each file where I want it
    - Creates the first child record then wloses the staffID and does not save the record.

Code as follows:
SaveFile::st:UploadCerts  Routine
  data
! Start of "Save File"
! [Priority 5000]

! End of "Save File"
  code
  ! Start of "Save File"
  ! [Priority 5000]
        IF p_web.GetValue('nosave') <> 1
            Clear(ECT:Record)
            ECT:staffid = p_web.GSV('st:staffid')
            ECT:CertLocation = p_web.GSV('st:UploadLocation')
            ECT:CertName = str.FileNameOnly(p_web.GSV('st:UploadCerts'))
            Access:empcerts.Insert()
            st:UploadCerts = clip(p_web.GSV('st:UploadLocation')) &'\' &ECT:CertName
            p_web.SSV('st:UploadCerts',st:UploadCerts)
            !MESSAGE(p_web.GSV('st:staffid')) -- this is correct
        END
  ! End of "Save File"
  p_web.SetSessionValue('_save_st:UploadCerts',st:UploadCerts)
  p_web.SaveFile('st:UploadCerts',st:UploadCerts)
  ! Start of "Save File"
  ! [Priority 5000]
 
  ! End of "Save File"

Thanks in advance

Brian.
Brian

DonRidley

  • Don Ridley
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 729
  • donaldridley2011@gmail.com
    • View Profile
    • Email
Re: File Uploads - multiple
« Reply #1 on: March 10, 2018, 08:23:27 AM »
I'm seeing the same thing on build 10.18. 

It had been working for years and stopped working. 

Do not know when it stopped.

Don
"Eliminate the impossible, whatever remains, however unlikely, must be the truth."

NetTalk 12.55
Clarion 11

broche

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Email
Re: File Uploads - multiple
« Reply #2 on: March 10, 2018, 12:08:29 PM »
Thanks Don, yes it seems to be associated with 10.18?
I think I understand the flow of the process.  Maybe it's a thread thing?
Brian

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11179
    • View Profile
Re: File Uploads - multiple
« Reply #3 on: March 11, 2018, 10:58:05 PM »
Hi Brian,

When you do a multi-select and "start" then all the files are sent up _at the same time_.
You'll see this in your log.

So you need to view this code with the thought that there are lots of procedures running this same code all at the same time.
Apart from the MESSAGE statement (always a REALLY bad idea, and a sign that you are not using Debugview...)

>> Creates the first child record then loses the staffID and does not save the record.

does not save _which_record? EmpCerts?  or the parent record?

cheers
Bruce






broche

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Email
Re: File Uploads - multiple
« Reply #4 on: March 12, 2018, 12:19:15 AM »
Guilty as charged on this one.  Will check with debugview.
Does not save the EmpCerts Record.  The Parent record (staff) already exists before all this happens.
Thanks.
Brian

DonRidley

  • Don Ridley
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 729
  • donaldridley2011@gmail.com
    • View Profile
    • Email
Re: File Uploads - multiple
« Reply #5 on: March 12, 2018, 01:49:24 AM »
If I conduct a multi file upload, it uploads the first file selected to the correct directory. The other selected files are not uploaded. 

However, all of the files' table records ARE correctly created. 

Don
"Eliminate the impossible, whatever remains, however unlikely, must be the truth."

NetTalk 12.55
Clarion 11

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: File Uploads - multiple
« Reply #6 on: March 12, 2018, 04:28:39 AM »
Hi Brian,

Along the line of what Bruce said. You need to "save" the value of st:staffid into a safe unused session variable, prior to the upload commencing. Then use that saved value to prime your ECT record.

Because, if your uploads can take some time your user might leave this screen and do something else that will change the value in your st:staffid session variable. If they do that your uploads
 (or some of them) will arrive for the wrong staff member, which can prove very unsatisfactory.

That said, I don't think its your actual problem here. Unless you have other code on this page which changes the st:staffid, in which case its probably your problem.

Regards
Bill


broche

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Email
Re: File Uploads - multiple
« Reply #7 on: March 15, 2018, 09:21:57 AM »
Thanks Bill, when I prime the update using Loc:StaffID it works just fine.  Saves correctly and creates all records as desired.
I am using autonumbering on the st.StaffID field and not sure where or when I can grab that ID.

Thanks.
Brian

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11179
    • View Profile
Re: File Uploads - multiple
« Reply #8 on: March 15, 2018, 11:54:58 PM »
If you are creating child records (image records) before the parent record has been inserted, then the ID field would not yet be set. So you have to force the form to Insert when the form is opened. This is done on the form settings, advanced tab, "Auto Inc even if not necessary". Then the staff ID is in the session value.

cheers
Bruce

broche

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Email
Re: File Uploads - multiple
« Reply #9 on: March 17, 2018, 03:10:03 AM »
Thanks Bruce, great - yes should have remembered that one, heard it in your webinars enough.
Brian