Current location: Hot Scripts Forums » General Web Coding » JavaScript » Pull File Name


Pull File Name

Reply
  #1 (permalink)  
Old 04-22-04, 06:00 PM
fs22 fs22 is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Pull File Name

I cannot see that there is a property where I can pull the file name from the document. What I am trying to do is where I have a local file located at c:\documents and settings....yada yada...\somefile.html, I need to pull the info somefile.html out of there and place that in a variable. Anyone ever done something like that?

~Clay
Reply With Quote
  #2 (permalink)  
Old 04-23-04, 03:30 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
Are you trying to access the file itself or are you trying just to retrive a string with the location of the file from some place on the page where it already exists?
Reply With Quote
  #3 (permalink)  
Old 04-23-04, 07:30 AM
fs22 fs22 is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
I am trying to setup bookmarking. When a user goes to a page (this will all be on their local harddrive aldo), I want that when they get to a page that it stores a bookmark. So I want to grab the file name and not the entire path name and store that file name to pull back into a hyperlink at a later time.
Reply With Quote
  #4 (permalink)  
Old 04-25-04, 11:27 AM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
can't you simply use window.location for that and just cut away everything before the last backslash?
Reply With Quote
  #5 (permalink)  
Old 04-26-04, 12:45 PM
fs22 fs22 is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by TwoD
can't you simply use window.location for that and just cut away everything before the last backslash?
How would I go about that?
Reply With Quote
  #6 (permalink)  
Old 04-26-04, 02:49 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
myVar = window.location.toString().substring(window.locati on.toString().lastIndexOf("/")+1)

That'll return everything after the last / in the location.

If you are using some kind of serverside script and don't want the stuff after ? use this instead.

myVar = window.location.toString().substring(window.locati on.toString().lastIndexOf("/")+1,window.location.toString().lastIndexOf('? '))
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Upload, File Type Check, File Size Check CarBoffin PHP 3 04-13-04 02:26 PM
Getting the created file (fopen/fwrite) Programme PHP 5 02-14-04 03:09 PM
write to beginning of file or reverse an array of binary data abtimoteo Perl 1 01-20-04 10:09 AM
Please I Need help before all my hair is gone! LisatheNovice Perl 6 11-22-03 03:05 PM
Upload file type and size limiter! Arctic ASP 1 08-02-03 07:06 PM


All times are GMT -5. The time now is 02:15 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.