NetTalk Central

Author Topic: Validating a filename for Uploading  (Read 3860 times)

Poul

  • Full Member
  • ***
  • Posts: 160
    • View Profile
Validating a filename for Uploading
« on: September 02, 2015, 12:20:47 PM »
I would like to validate the File name being uploaded
which appears to be something i can only do after the File is actually transferred.

Currently I can reject the file, but was looking for a simple way to convey this to the User
I currently have an Alert but after clicking ok the
Upload button text says "Uploaded" and i would like to conditionally indicate its invalid - - "Wrong File name"
and re-arm things so the user can try again.

In an ideal world i would like to pass the file name (or Mask like *.PDF) to the jquery bit, so it can validate
or abort the Update if its not a Specific value (before it finishes the upload) and update the user appropriately.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Validating a filename for Uploading
« Reply #1 on: September 03, 2015, 12:18:21 AM »
Hi Poul,

you can set the "file selector" in the browser to be like "*.pdf" as the initial list of files, but of course nothing stops a user adding some other file if they want to .

At the moment I don't have any JavaScript in that enforces the file extension before upload.

cheers
Bruce

Poul

  • Full Member
  • ***
  • Posts: 160
    • View Profile
Re: Validating a filename for Uploading
« Reply #2 on: September 03, 2015, 07:16:22 AM »
Quote
you can set the "file selector" in the browser to be like "*.pdf" as the initial list of files,
any tips on how to do that?  Chrome and FF seem to be *.* only?

i was poking around at http://blueimp.github.io/jQuery-File-Upload/jquery-ui.html
and the demo does limit the  filetypes - though its not clear if thats additional server code or not.

the documentation on acceptFileTypes seems to be what i want.


drat, i just realized my NT is bit older and you added acceptFileTypes  support a few months back
i need to regroup!

thanks  poul

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Validating a filename for Uploading
« Reply #3 on: September 03, 2015, 09:19:30 PM »
ha ha - well you gotta keep up mate <g>

cheers
Bruce