Solved

Use Jquery or AJAX to check if a file exists

Posted on 2013-05-15
5
1,062 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 83

Expert Comment

by:Dave Baldwin
ID: 39169055
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
ID: 39169216
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
ID: 39169217
And if so, how?
thanks again for replying
0
 
LVL 53

Expert Comment

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

Cd&
0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 39169535
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to create an extensible mechanism for linked drop downs.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

856 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