• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1258
  • Last Modified:

Use Jquery or AJAX to check if a file exists

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
badwolfff
Asked:
badwolfff
1 Solution
 
Dave BaldwinFixer of ProblemsCommented:
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
 
badwolfffAuthor Commented:
At present the site is on localhost
and once it works I will transfer it to a server.
Can it be done?
0
 
badwolfffAuthor Commented:
And if so, how?
thanks again for replying
0
 
COBOLdinosaurCommented:
Of course it can be done on the server.  The scripting is trivial in any commonly used server side scripting language.

Cd&
0
 
Chris StanyonCommented:
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now