get files of a folder on the web

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

get files of a folder on the web

Post by jmburnod » Sun Nov 27, 2011 5:27 pm

Hi All,

I thought

Code: Select all

on mouseUp
   set the defaultfolder to "http://www.alternatic.ch/jmb/DesImages/"
   put the files
end mouseUp
work, but it return the files of the old defaultfolder

What i forget ?

Best regards

Jean-Marc
https://alternatic.ch

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: get files of a folder on the web

Post by Klaus » Sun Nov 27, 2011 5:49 pm

Hi Jean-Marc.

setting the defaultfolder to any folder on the internet does not work as on the desktop!
But I have no idea what you could do instead 8)

Some servers will return a file listing, probably in HTML format!, if you just get the FOLDER address and there is NO "index.html" in that folder,
but this is mostly forbidden for security reasons:
...
put url "http://www.alternatic.ch/jmb/DesImages/"
...
Gives: error 403 Forbidden


Best

Klaus

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: get files of a folder on the web

Post by jmburnod » Sun Nov 27, 2011 11:03 pm

Hi Klaus,

Thank for quick reply
setting the defaultfolder to any folder on the internet does not work as on the desktop!
It work on IOS ?
Some servers will return a file listing, probably in HTML format!, if you just get the FOLDER address and there is NO "index.html" in that folder,
but this is mostly forbidden for security reasons:
Ok i can upload a text file with the list of files and reading it.

Best

Jean-Marc
https://alternatic.ch

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: get files of a folder on the web

Post by Klaus » Mon Nov 28, 2011 10:59 am

Bonjour Jean-Marc,
jmburnod wrote:
setting the defaultfolder to any folder on the internet does not work as on the desktop!
It work on IOS ?
No, I mean the internet in contrary to LOCAL files/folders :D
jmburnod wrote:
Some servers will return a file listing, probably in HTML format!, if you just get the FOLDER address and there is NO "index.html" in that folder,
but this is mostly forbidden for security reasons:
Ok i can upload a text file with the list of files and reading it.
Ah, yes, if that is possible, that will be the best way!

Best

Klaus

P.S.
I found a PHP snippet on my HD taht will return a file listing of the folder where the PHP script resides!
Just copy this into a new textfile, save it as: filelisting.php
in the folder on your server and you will always have an up-to-date file listing with:
...
put url"http://www.yourserver.com/folder1/filelisting.php" into field "Files on server"
...

Code: Select all

<?php
if ($handle = opendir('.')) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            echo "$file\n";
        }
    }
    closedir($handle);
}
?>

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: get files of a folder on the web

Post by jmburnod » Tue Nov 29, 2011 12:10 am

Hi Klaus,
Great :D
I will test it wenesday
Thank one more
Best

Jean-Marc
https://alternatic.ch

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: get files of a folder on the web

Post by jmburnod » Wed Nov 30, 2011 6:42 pm

Hi Klaus

I tested the php way but it return empty

i put a little stack in attachment

Best

Jean-Marc
Attachments
GetFilesOfFolderOnServer.livecode.zip
(1.01 KiB) Downloaded 264 times
https://alternatic.ch

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: get files of a folder on the web

Post by mwieder » Wed Nov 30, 2011 7:03 pm

That seems like the correct behavior. If I test the url in your stack it returns empty. Put "http://www.alternatic.ch/jmb/DesImages/filelisting.php" into a browser and there's nothing returned. I don't get a "not found" error, so the php code is executing on the server.

OTOH I get file permissions trying to access the web site folder at either jmb or DesImages, so there may be some permissions problems as well. I think you need to make sure the php code on the server is working before trying to troubleshoot the LC script.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: get files of a folder on the web

Post by Klaus » Wed Nov 30, 2011 7:24 pm

Hi Jean-Marc,

I tested your stack and got "error 500 Internal Server Error" in THE RESULT.
I have tested the PHP script before and know that it is working (although I have no idea why :D )

So there must be something going on on your server, maybe there is no PHP engine installed?
Although I doubt this!


Best

Klaus

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: get files of a folder on the web

Post by sturgis » Wed Nov 30, 2011 7:59 pm

A slightly OT question re: php and file listings.

Since I don't understand enough php to know whats going on with this code..

Code: Select all

<?php
if ($handle = opendir('.')) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            echo "$file\n";
        }
    }
    closedir($handle);
}
?>

I tried this instead.

Code: Select all

<?php
echo shell_exec('ls');
?>
Are there reasons to avoid shell_exec? Security or otherwise? Maybe shell_exec isn't always allowed I guess, so maybe thats why. Just a curiosity question, both work fine for me on on-rev.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: get files of a folder on the web

Post by jmburnod » Thu Dec 01, 2011 10:08 am

Hi,
Thank for reply
So there must be something going on on your server, maybe there is no PHP engine installed?
Although I doubt this!
I have sent a message to the administrator of alternatic.ch

Best regards

Jean-Marc
https://alternatic.ch

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: get files of a folder on the web

Post by jmburnod » Tue Dec 20, 2011 11:08 pm

Hi Sturgis,

Thank for reply
I send your script to the alternatic administrator

Klaus:
We tested your script with an other serber and it work well

Best regards

Jean-Marc
https://alternatic.ch

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: get files of a folder on the web

Post by jmburnod » Wed Dec 21, 2011 12:48 pm

Hi,

Someone send me a php script of Greg Johnson and it work with the site
alternatic.ch (there is a spip on a Linux server)

I put an example stack in attachment

I do not still know why the script of Klaus does not work (with this server only)

Best regards

Jean-Marc
Attachments
GetFilesOfFolderOnServer2.livecode.zip
(21.12 KiB) Downloaded 264 times
https://alternatic.ch

Post Reply