Solved

Use Jquery or AJAX to check if a file exists

Posted on 2013-05-15
5
990 Views
Last Modified: 2013-07-08
How could I use jQuery or AJAX to check if there are:
1) a pdf
2) and an mp4
files in a folder?
I know the file names, if that is useful.

thanks in advance
0
Comment
Question by:badwolfff
5 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
You would have to have a program on the server that you contact that can check to see if the files are there.  You can't check anything on the user's local machine.
0
 

Author Comment

by:badwolfff
Comment Utility
At present the site is on localhost
and once it works I will transfer it to a server.
Can it be done?
0
 

Author Comment

by:badwolfff
Comment Utility
And if so, how?
thanks again for replying
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
Of course it can be done on the server.  The scripting is trivial in any commonly used server side scripting language.

Cd&
0
 
LVL 42

Accepted Solution

by:
Chris Stanyon earned 500 total points
Comment Utility
As has already been said, you need a program/script sat server-side - something like PHP or ASP. You will then code your javascript to call that file, which in turn will read the folder and check for the files and spit out some kind of result - TRUE / FALSE etc. which is returned to your Javascript.

PHP has a function called file_exists() - returns a BOOLEAN value,  so your script mught be as simple as:

<?php echo file_exists('somefile.mp4'); ?>

Open in new window

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now