NetTalk Central

Author Topic: NT7 New File Upload Issues.  (Read 2766 times)

Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
NT7 New File Upload Issues.
« on: February 04, 2013, 09:25:18 PM »
First of all, I like the enhancement to File Upload button. But I have some issues in using the new features.
1) Bug. If Field Name and the Equate  values on the File Upload button are different, then the program will crash when uploading a file.
2) Why does the file upload field and browse button still appear in my program, (See MyUploadButton.jpg),  where they do not appear in the example 26 program (see ExampleUpLoadButton.jpg). Also the “Add” button does not work in my program. The user must press the browse button to select a file. I cannot see any difference in the setting of the upload button in the two programs and I have deleted and recreated all the buttons in the net talk extension of the web server.  I have done clean rebuilds, etc. The problem occurs on all browsers including the latest version of Firefox browser.  The only difference, I can think of is the NetWebForm of the example updates an actual field in a database record whereas in my program the form updates a local variable  is a memory form. But they both do upload a file.
3) In NT6, Bruce told me that the size of the uploaded file is in the p_len variable of the HandleFile  web handler method. This method no longer is used. Where can I get the file size  now? (I know that the file is already uploaded at this point.)

Suggested improvements.
1) Since I have a number of customers that still use browsers that do not support HTML 5,  it would be nice to have a conditional field to validate on when to use the old or new method. Or where the browser does not have adequate HTML 5 capabilities to retrieve the file size, then simply not displayed file size with file. Typical user will not know why  “NA MB” is being displayed.
2) When only one file is permitted to be uploaded, remove the unnecessary buttons (see MultipleUploadButtons.jpg). Only one button is needed to start the upload and remove the name of the file to be uploaded.
3) Client side validation of requested file size and/or file extension. I do not think that HTML 5 capabilities would be necessary to validate the file extension of the selected file is in a list of extension. 

Rob

[attachment deleted by admin]

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11179
    • View Profile
Re: NT7 New File Upload Issues.
« Reply #1 on: February 04, 2013, 11:17:22 PM »
Hi Rob,

>> 1) Bug. If Field Name and the Equate  values on the File Upload button are different, then the program will crash when uploading a file.

I don't get a crash, but the file isn't uploaded - so I've fixed that on this side. (the fix will be in 7.05)

>> 2

regarding the button - I don't know why it's misbehaving for you. Any chance I can see an example app? Maybe it's css related?

>> 3) In NT6, Bruce told me that the size of the uploaded file is in the p_len variable of the HandleFile  web handler method. This method no longer is used. Where can I get the file size  now? (I know that the file is already uploaded at this point.)

short answer;

the length of the incoming file is now accessible in

self.GetValue('name_length')

where name is the FieldName (not the Field Equate)

longer answer;

7.05 adds a template setting so you can set the maximum file size of a Post. (WebServer procedure, Security tab). See the release notes and associated docs for more on this. If you are wanting to limit the incoming size, this is the place to set it.

even longer answer;

the saving of the file to disk is called by the form - there's a routine in there called;

savefile::fieldequate  routine

this in turn calls the .SaveFile method in the WebHandler. There are two .SaveFile methods in the web handler - the one with the length allows you to override the same (globally) if you like, depending on the length. ie you can test the length and Return before the parent call if you like.

>> 1) Since I have a number of customers that still use browsers that do not support HTML 5,  it would be nice to have a conditional field to validate on when to use the old or new method

The upload should work ok on all (reasonable) browsers. I've tested here on IE7 and up (albeit that I needed to make a small fix for IE7) and it works so I think we're ok on that front. It's worth pointing out that this isn't really HTML 5 - it falls back on a couple techniques for less modern browsers already. If there is a problem with a specific browser please let me know. (Progress bars don't work on all browsers - specifically IE - but that's no worse than the old way.)

>> 2) When only one file is permitted to be uploaded, remove the unnecessary buttons

done.

>> 3) Client side validation of requested file size and/or file extension. I do not think that HTML 5 capabilities would be necessary to validate the file extension of the selected file is in a list of extension. 

This won't make it into the 7.05 build - it's quite a bit of work because it involves both the client and the server, but I've added it to the list.

cheers
Bruce


« Last Edit: February 05, 2013, 12:04:33 AM by Bruce »

Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: NT7 New File Upload Issues.
« Reply #2 on: February 06, 2013, 11:40:04 AM »
Hi Bruce,

1) Bug ...
>>I don't get a crash, but the file isn't uploaded - so I've fixed that on this side. (the fix will be in 7.05)

You likely did not crash because your program was compiled in release mode. The error is regarding a index that is out of scope that only appears when the program is compiled in debug. Nevertheless the file is not uploaded and your fix will likely correct the problem.

2) Why does the file upload field and browse button still appear in my program, (See MyUploadButton.jpg),  where they do not appear in the example 26 program (see ExampleUpLoadButton.jpg). ...
>> regarding the button - I don't know why it's misbehaving for you. Any chance I can see an example app? Maybe it's css related?

I figured out what cause the file upload field and browse button still appear, I believe it is a bug. Change the advance tab of net talk extension of the web server example 26 program to "Combine Common Files" and recompile. The file upload field will appear like in the "MyUploadButton.jpg".  Hopefully this fix can be in the 7.05 release as well. I believe there is a performance advantage in combining the script files into one compressed file.

Thanks Rob

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11179
    • View Profile
Re: NT7 New File Upload Issues.
« Reply #3 on: February 06, 2013, 05:26:19 PM »
7.05 is already up Rob, but I'll check out the combined thing for 7.06.
Thanks for the info.

cheers
Bruce

Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: NT7 New File Upload Issues.
« Reply #4 on: February 08, 2013, 08:45:11 AM »
Hi Bruce,
Another question on this topic. From inspecting the generated clarion code, it appears to me that the upload fieldname validation occurs after the file is uploaded into memory, but before the SaveFile… routine is called which creates the file.  If my  filename validation code rejects the uploaded file, can I skip the call to the SaveFile… routine and thus prevent the file from being created.  Is there any problem in leaving the uploaded file in memory ?  will the memory be overwritten by the next Post transaction? Or should I let the file be created and then delete the file?

Thanks,
Rob

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11179
    • View Profile
Re: NT7 New File Upload Issues.
« Reply #5 on: February 08, 2013, 10:58:17 PM »
>>  it appears to me that the upload fieldname validation occurs after the file is uploaded into memory, but before the SaveFile… routine is called which creates the file.

yes.

>> If my  filename validation code rejects the uploaded file, can I skip the call to the SaveFile… routine and thus prevent the file from being created.

well yes, put the validation (or call the validation) from the top of the SaveFile routine, and then Exit if it fails.

>>  Is there any problem in leaving the uploaded file in memory ? 

no.

>> will the memory be overwritten by the next Post transaction?

no, the memory will be disposed when the thread ends (ie within around a tenth of a second). The file is parsed into a Value parameter, and like all Value parameters is bound to the thread. Which is about to die.

>>  Or should I let the file be created and then delete the file?

nope, not necessary.

Cheers
Bruce


Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: NT7 New File Upload Issues.
« Reply #6 on: February 14, 2013, 09:56:18 AM »
The following is feedback from our testers regarding the new NT7 file uploader. In our application, the file upload field option  "Allow Multiple Selection" is unchecked and only one file will be processed by the application at a time.  I am not sure if there are any quick fixes here, but these are enhancements that we would like to see.  My comments are in brackets.

1. Clicking on the "Ajouter un fichier" (French for "Add File") does not always work. (I verified with the user, that the button does not work when clicked on the first half of the button. I believe the issue is that the "Add File" button is a cover over the browser’s browse button and French text is longer. This not a big deal to me, but users can get frustrated real fast over small issues.)
2. After a file has been uploaded, the "Add File" button still operates, which gives the  impression that more files can be uploaded when only the last upload is used. (Can the "Add File" be hidden after the first file is uploaded, if  the "Allow Multiple Selection" option is unchecked. I tried to do this but coding the file upload field as hidden in the field validation, then refresh the field. But nothing changed.)
3. How come there are two progress bars when the file is uploaded? (Can the overall progress bar be hidden when "Allow Multiple Selection" option is unchecked.)
4. When the upload is started can the status be changed from "Waiting…" to "Uploading…". (This would be ideal for my customers that are forced to use IE8 where the progress bars to not work. Also when IE8 is used can the progress bars be hidden. Thus the IE8 user would see the following statuses:  "Waiting…" after the file is selected, "Uploading…" after the Start button is pressed, then "Uploaded" when the file is upload. )

Attached are images sent from the tester for numbers 2 and 3.

Thanks,
Rob


[attachment deleted by admin]

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11179
    • View Profile
Re: NT7 New File Upload Issues.
« Reply #7 on: February 20, 2013, 03:08:16 AM »
thanks for all the feedback Rob, it's really useful.

>> I believe the issue is that the "Add File" button is a cover over the browser’s browse button and French text is longer.

while there are some limits here, I've tweaked the CSS in 7.06 to hopefully make this a bit "better". Let me know.

>> After a file has been uploaded, the "Add File" button still operates,

I've added a template option for this "Only allow 1 upload". I figure it's a sub-setting of "allow multiple" because it might be nice to allow a "correction" if they upload the wrong file.

>> Can the overall progress bar be hidden when "Allow Multiple Selection" option is unchecked

done.

>> When the upload is started can the status be changed from "Waiting…" to "Uploading…".

done

>> Also when IE8 is used can the progress bars be hidden.

done

all the above in 7.06

Cheers
Bruce


Rob Kolanko

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: NT7 New File Upload Issues.
« Reply #8 on: February 22, 2013, 12:27:40 PM »
Bruce,
Have you investigated why the Add button does not cover the standard file upload controls when "Combine Common Files" option is selected for styles? Please see my Feb 6 post ablove. Will we be able to the "Combine Common Files" option in 7.06?

Thanks
Rob

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11179
    • View Profile
Re: NT7 New File Upload Issues.
« Reply #9 on: February 24, 2013, 11:25:10 PM »
yes.