Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 25th, 2004, 09:02 PM
Authorized User
 
Join Date: Jun 2003
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to tdaustin Send a message via Yahoo to tdaustin
Default Getting file extention

Hi Everyone,

im doing a file upload and creating a random file name. I need to add the random string to the extention of the file uploaded. I currently have it working by grabbing the 4 right charaters, but if they upload a file with more that 3 (.html) it will corrupt the file when saving.

How can i detect the . in the string and grab what evers after it?

Also how can i check that there is on 1 . in the file?

Code:
'Generate Random file name
      dim max,min
      max=99999999
      min=20000000
      RanFileName = (Int((max-min+1)*Rnd+min))
      ' Add extension
      FileExt = Right(file.FileName, 4)
      ' Merge Random File Name and extention
      FileName = RanFileName & FileExt
Thanks

Tim

TDA
__________________
TDA
 
Old July 25th, 2004, 09:10 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

You can split the file name on the '.' and then use the last array element

arrFileName = split(YourFileName,".")
fileEXT = "." & arrFileName(ubound(arrFileName))


======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old July 26th, 2004, 01:45 AM
Authorized User
 
Join Date: Jun 2003
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to tdaustin Send a message via Yahoo to tdaustin
Default

Thanks,

worked gr8

Tim :)

TDA





Similar Threads
Thread Thread Starter Forum Replies Last Post
Read Text file and convert to Binary file VB.net sjlsysprg1 Pro VB.NET 2002/2003 4 June 29th, 2007 06:53 AM
Filter File Types in ASP.NET File Upload ramuis78 ASP.NET 2.0 Basics 2 May 31st, 2007 10:50 AM
Oracle Jdeveloper extention functions arjamit XSLT 1 May 9th, 2007 08:43 AM
How to display .tif file, .pdf file and .jpg file phuong171 ASP.NET 1.0 and 1.1 Basics 1 March 13th, 2007 07:29 AM
chart extention recommendations? ss2003 Beginning PHP 5 January 8th, 2004 05:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.