[SOLVED] JS Does File Exist |
7/26/2022 2:57:30 AM |
PHPRunner General questions | |
A
asawyer13 authorDevClub member
I want to check to see if a particular file exists on the local system. If it doesn't, I want to hide a button that's on my list page.
var myfile = new File("help/File1.html"); if (!myfile.exists) {
I believe the hide of the button works by itself, but not working if the file doesn't exist. Alan |
|
A
|
asawyer13 authorDevClub member 7/26/2022 |
The code is in the Javascript On Load event of the List Page |
A
|
asawyer13 authorDevClub member 7/26/2022 |
Well I thought the hide button code worked, but now not so sure. Can someone show me the right way to do this? Either in JS or PHP. Alan |
A
|
asawyer13 authorDevClub member 7/26/2022 |
I think I can do this in php code in the Before Display event. Let me try that. Alan |
A
|
asawyer13 authorDevClub member 7/26/2022 |
So I decided to do in the Before Display event $filename = 'help/file1.html'; if (file_exists($filename)) { Seems to work just perfectly. Alan |
![]() |
Admin 7/26/2022 |
Javascript doesn't have access to the file system so you can only use PHP for this kind of task. |