?
Solved

Use Jquery or AJAX to check if a file exists

Posted on 2013-05-15
5
Medium Priority
?
1,158 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 84

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 1000 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

What is a Denial of Service (DoS)?

A DoS is a malicious attempt to prevent the normal operation of a computer system. You may frequently see the terms 'DDoS' (Distributed Denial of Service) and 'DoS' used interchangeably, but there are some subtle differences.

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.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
Suggested Courses

762 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