Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6013291
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:31:38+00:00 2026-05-23T02:31:38+00:00

I used this: $(‘input[type=file]’).val() to get the file name selected, but it returned the

  • 0

I used this:

$('input[type=file]').val()

to get the file name selected, but it returned the full path, as in “C:\fakepath\filename.doc”. The “fakepath” part was actually there – not sure if it’s supposed to be, but this is my first time working with the filename of file uploads.

How can I just get the file name (filename.doc)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:31:39+00:00Added an answer on May 23, 2026 at 2:31 am
    var filename = $('input[type=file]').val().split('\\').pop();
    

    or you could just do (because it’s always C:\fakepath that is added for security reasons):

    var filename = $('input[type=file]').val().replace(/C:\\fakepath\\/i, '')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used this code to print the current page: <form> <input type=button value=Print onClick=window.print();
i used this line of code but it didn't work $(a#link).attr(href,$(this).attr('tempref').val());
I used this code to read file. But fread function always return 0. What
I used this guide on Apple's website to enable PHP on my computer but
Has anyone used this plugin? I don't know if my setup is right, but
One of our developers used this call: TzSpecificLocalTimeToSystemTime() but unfortunately we cannot keep it
Example: If I used this, where does the iPhone store the file? if (![NSKeyedArchiver
I have used this code for extracting urls from web page.But in the line
I used this code to add the data in the mysql table. But I
I used this command to find mp3 files and write their name on log.txt:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.