views:

46

answers:

1

Hello!

I'm trying to list all files (. DOC and. PDF) contained in a specific Web directory.

The problem is that I do not have access. I can only download with the full path of the file.

Example:

Directory 1: http://xxx.site.com/uploads/local20/40

Files:

45677.pdf

54354.doc

65767.doc

54354.pdf

43243.pdf

...

Directory 2: h t t p:// xxx . site . com / uploads / local20 / 41

Files:

45453.pdf

67566.pdf

89798.pdf

89898.doc

52254.pdf

...

I can manually download the files of directory 40 and 41, because I know your path, then write: h t t p:// xxx. site . com / uploads / local20 / 40 / 65767.doc (Download -> OK)

But how to download all the files contained in this directory without knowing the names of files? Or at least list the names of all files.

Obs 1: When I type only the directory (without the name of the file) it returns me an error in XML format. Ex: h t t p: // xxx . site . com / uploads / local20 / 40/

Response: XML Error

...

NoSuchKey

...

Obs2: The Web application use the PHP language.

...

Any suggestions would be appreciated.

Thanks.

A: 

In order to have the files in a folder listed out in html format when you browse to that folder with a web browser, you'll have to turn on directory browsing in your Apache configuration and make sure you don't have a default page (eg. index.php) in that folder. Don't forget to restart Apache after making the change.

BTW: If this is a folder where files can be uploaded, it really shouldn't be directly publicly accesible because you'll have a pretty major security vulnerability on your hands. Someone can upload a malicious PHP script and then run it by simply hitting the URL in a browser.

Asaph
Asaph,I don´t have access to the Apache server. Need another way to list the files... "sure you don't have a default page (eg. index.php) in that folder" -> Tested - OK. (Don´t have a default page in that folder).Any more suggestions?
Paul Lopes
Asaph,I have a solution (Robot Software) that would automatically download using the filename codes range (/1000.DOC, /1001.DOC, /1002.DOC , ...), but many would be invalid files and other valid files.What do you think of this solution?
Paul Lopes
@Paul Lopes: I'm not sure I understand completely. By "Robot Software", do you mean a script that will read the contents of a directory and generate an HTML page with links? Or a script that guesses what files might be in a directory based on some assumptions?
Asaph
@Asaph,Patching: It would be a program (Offline Browser - Extractor) that would download all the URLs that mount in the SQL statement.Example:http://http://xxx.site.com/uploads/local20/40/65000.dochttp://http://xxx.site.com/uploads/local20/40/65001.dochttp://http://xxx.site.com/uploads/local20/40/65002.dochttp://http://xxx.site.com/uploads/local20/40/65003.doc...http://http://xxx.site.com/uploads/local20/40/90000.docSome would be invalid, but others would be valid files Doc. What do you think of this solution?
Paul Lopes
@Paul Lopes: Why would some of them be invalid?
Asaph
@Asaph: The files that are in directories with their codes are not sequential (Example: 1000.DOC, 1020.DOC, 1202.DOC, 1300.DOC). And I have no access to the list of files, so I picked up a range, in this case, [1000 to 1300]. Result: 4 Valid AND 296 Invalid Files.
Paul Lopes
@Asaph: Correcting -> Invalid = Not found on server ...The files that are in directories with their codes are not sequential (Example: 1000.DOC, 1020.DOC, 1202.DOC, 1300.DOC). And I have no access to the list of files, so I picked up a range, in this case, [1000 to 1300]. Result: 4 Valid AND 296 Not Found Files...
Paul Lopes
@Paul Lopes: I suppose that would work but this solution is not as elegant as one that queries the server for a list of files and then downloads the ones that are returned.
Asaph
@Asaph: I agree. But as the list (files) without having access to Apache Server (turn off directory browsing Apache)? Is there another way around this?
Paul Lopes
@Paul Lopes: You could write a php script that reads the contents of a directory and outputs the results.
Asaph
@Asaph: The PHP application is hosted in another city and I am only web user of application trying to download some files of interest of personal interest in this application. I have not access to PHP code application, SQL database, Apache Server, etc...
Paul Lopes
@Asaph: I do not know PHP. I am programmer in C#, ASP.Net, SQL SERVER 2008. Any suggestions to try to list the files using only the HTTP and FTP?
Paul Lopes
@Paul Lopes: Sorry, you can always try to learn a little PHP. One of PHP's great strengths is it's shallow learning curve. Good luck!
Asaph
You could try using a .htaccess file instead of modifying the apache configuration. And while you cannot list files with HTTP, you sure can list them with FTP.
igorw