File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Check for File Exists using Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "Check for File Exists using Javascript" Watch "Check for File Exists using Javascript" New topic
Author

Check for File Exists using Javascript

Shrinivas Mujumdar
Ranch Hand

Joined: Aug 27, 2004
Posts: 328
Hi,

I am coding a JSP file, where there is a need for File Upload. I am using
<input type="file" ...> tag.

Now, suppose end user enters some garbage value in Textfield (in File Upload control), & clicks Submit button it gives javascript error on status bar ('Error on Page' on left hand side bottom region), It says Access is Deniedwhere i am trying to submit this form. If i browse some file using Browse button it works fine.

On click of a Submit button, i am calling a Javascript function which checks for 'Submit' button click & if Submit is clicked, sets action (.action) property to neccessary URL & submits the page to new action url. With alert i have checked for the correctness of the URL & it is fine in both cases.

My question is, Is it possible somehow so that i could say to a user that "file name is incorrect" or similar.

I can't check for file path as this system could be accessed from Windows as well as Linux OS machines.

Thanks in Advance,
Shriniwas
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15357
    
    6
JavaScript can not access the local file system so there is nothing you can do to see if a file exists.

Eric
Shrinivas Mujumdar
Ranch Hand

Joined: Aug 27, 2004
Posts: 328
Thanks Eric,

Do you suggest any solution for the above mentioned problem?

Rather, it's not specific to Eric , it's open for everybody.

Thanks in Advance,
Shriniwas
Garrett Smith
Ranch Hand

Joined: Jun 27, 2002
Posts: 401
you could try blurring the file control onfocus:


comp.lang.javascript FAQ: http://jibbering.com/faq/
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56168
    
  13

Originally posted by Garrett Smith:
you could try blurring the file control onfocus:


How would this help acertain that the file path is correct?


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Check for File Exists using Javascript
 
Similar Threads
Passing data between pages/requests - Best practice
HTML DOM to create file upload button(Browse)
How to Upload the Client File To The Server
FTP via web application
Access Denied When Submitting File Upload