tags:

views:

361

answers:

3

I am using Flex with Flash player. I know with AIR i can access the file system but i am not using AIR.

Can my application check if a particular file exist when an HTTPService is sent?

+1  A: 

You can check if a file exists on the local file system using:

import flash.filesystem.*;

var temp:File = File.createTempFile();
trace(temp.exists) // true
temp.deleteFile();
trace(temp.exists) // false

Are you wanting to check if the file exists on the remote machine, the one you are making the HTTP request to?

gonzohunter
Yes, i want to see if a particular file exits on server to which HTTP request was made.
baltusaj
For a particular local file in AIR, you can create with var f:File = new File(path);In Flash Player, you have no power to check local files.Not what you're looking for (server files), but worth noting with this response.
Michael Brewer-Davis
Ok Thanks Michael.
baltusaj
+1  A: 

The way I solve this problem is to make the request to the server. I then handle the response and check what is in the response. There should be an error in the response if the file was inaccessible.

Although, this could also mean the URL is wrong or that the server refused connection

gonzohunter
A: 

If you are checking to see if a file exists on the server, it's going to be a server side solution, not a Flex solution. You need some kind of server side scripting language set up (like PHP) that can take the HTTP request, check for the file on the server and then return a response. Should be a pretty easy problem to solve but it has nothing to do with Flex.

Osman
I will use PHP then but I am still searching for real time communication between PHP and Flex. By real time I mean something like, for example, displaying multiple echo statements of php in a Text Area of Flex. For now if I use multiple echo statements, they appear in the Text Area at once, most probably i use {service.lastResult} where service is my HTTPService's ID. Anyways thanks for you help. :)
baltusaj