SlickUpload
Welcome Guest Search | Active Topics | Log In | Register

Validate Filename before upload Options
jshivok
#1 Posted : Wednesday, April 21, 2010 11:53:00 AM
Rank: Newbie

Groups: Registered

Joined: 3/30/2010
Posts: 8
Location: PA

Is it possibly to validate a filename before upload? The files need to be named a certain way to be accepted so I want to do this pre upload. I already use the controls built in method for limiting file extentions but am unclear how to gain access to the selected filename field through java script(since it needs to run client side) and how to trigger the script to run when a file is selected?  Any help would be appreciated.

 

Thanks!

Axosoft
#2 Posted : Thursday, April 22, 2010 12:17:52 PM
Rank: Administration


Groups: Administrators

Joined: 7/7/2005
Posts: 1,586
Location: Scottsdale, AZ

Do you want to display an error message next to the file or keep it from being added entirely?

If you want to display an error message, you can use the OnClientFileAdded attribute to set a javascript method to call when the file is added. Something like this:

OnClientFileAdded="onFileAdded"

function onFileAdded(file)
{
// validate the file and show a message
}

If you want to keep the file from being added in the first place, you can use the OnClientFileAdded attribute to set a javascript method to call when the file is added. Then return true or false depending on whether you want the file to be added. Something like this:

OnClientFileAdded="onFileAdded"

function onFileAdded(file)
{
// validate the file and show a message
var fileIsValid = true;

if (fileIsValid)
return true;
else
return false
}

jshivok
#3 Posted : Thursday, April 22, 2010 1:54:42 PM
Rank: Newbie

Groups: Registered

Joined: 3/30/2010
Posts: 8
Location: PA
Perfect, Thanks!
shedezy
#4 Posted : Friday, April 30, 2010 4:56:02 PM
Rank: Newbie

Groups: Registered

Joined: 4/30/2010
Posts: 6

In validating, is there a way to assign the value of the filename about to be uploaded to another control on the form?

 

Like adding the following to your function

 

document.getElementById('Label1').value = ??????????

Axosoft
#5 Posted : Saturday, May 01, 2010 11:34:38 AM
Rank: Administration


Groups: Administrators

Joined: 7/7/2005
Posts: 1,586
Location: Scottsdale, AZ

Sure. The file object passed to the handler has a fileName property (see the docs here: http://krystalware.com/Products/SlickUpload/Documentation/client-reference/file.aspx).

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.