I have a question that may sound pretty basic but since I’ve never done anything like this I don’t know where to start let me explain.
I need an App (Mac) that I’m developing for a specific client to do when opening a check if a file exists (.txt) in a folder on their site and if it doesn’t exist returns with a message.
It would go to www.sitexxx.com/ files/ ACT.txt and if the file does not exist the program returns an error message in a Msgbox.
Again thanks so much and Jean-Yves Pochez for the help you are giving me !
Julian I don’t know what may be happening, but when I change the project path to my site (or any other fiction) and do the test it always returns True.
To be clear, I just opened the project that kindly sent me and changed the address (Path) and return true every time, I don’t know what could be going wrong, any idea why this is happening?
If your server doesn’t include the string “404 - File Or directory Not found.” in the source when the file is not found then it won’t match correctly, you’ll need to tweak that as I mentioned above. If your server does any redirection or uses https then the code will also need to be tweaked. PM me the full URL if you want and I’ll take a quick look.
Yeah, there are all these variables that can make it difficult if I need to target more than 1 server or even replace it, I think I’ll have to think better about it because I imagined a simple system to recognize whether a page exist and return me a true or false but I will have to think better.
Maybe I’ll even have to study a bit of how access via database this, anyway thanks for the immense help you gave me!
I use this, but it relies on knowing what the file content should be, rather than whether a page ‘exists at all’
On my site I have an XML file sitting
This checks whether it exists and is XML
[quote=462504:@Jeff Tullin]I use this, but it relies on knowing what the file content should be, rather than whether a page ‘exists at all’
On my site I have an XML file sitting
This checks whether it exists and is XML
In the Xojo code, I use a HTTPSocket and connect to the php file:
HS1.Get(app.RegURL) 'e.g. in the open event
In the HTTPSocket’s PageReceived, the content variable is 0 or 1, what the php script wrote.
Once this works, you can pass parameters to, for example, test for other files, if you want to reuse the php script for more than one file:
HS1.Get(app.RegURL+"?filename="+File.Name)
(don’t forget to grab the parameter in the php file; also, encrypting the passed name is a good idea, so eventual hackers won’t be able to use your script to test for random file existences).
[quote=463225:@Arnaud Nicolet]The way I do it (for the records) is the other way around. It works fine, though I’m not sure if there are drawbacks in this design.
In the Xojo code, I use a HTTPSocket and connect to the php file:
HS1.Get(app.RegURL) 'e.g. in the open event
In the HTTPSocket’s PageReceived, the content variable is 0 or 1, what the php script wrote.
Once this works, you can pass parameters to, for example, test for other files, if you want to reuse the php script for more than one file:
HS1.Get(app.RegURL+"?filename="+File.Name)
(don’t forget to grab the parameter in the php file; also, encrypting the passed name is a good idea, so eventual hackers won’t be able to use your script to test for random file existences).[/quote]
Thanks Arnaud Nicolet for your suggestion, i will try this too.
I have this project stopped in recent days, but will be back soon.