Does Javascript support the ability to get a direc

2019-07-30 03:17发布

I want to upload a bunch of image files to a directory that I've set up on my ISP's free hosting service. It's something like http://home.ISPname.net/~username/subdir.

I want my Javascript code to be able to get a directory listing and then preload whatever it finds.

But getting such a thing even possible? My impression is not.

I suspect I will have to instead rename my files to 00000.jpg and upward, and attempt to detect what files are there using try.

FYI, I know that my ISP does not support using FTP protocol to get a directory listing.

Thanks for any help.

2条回答
成全新的幸福
2楼-- · 2019-07-30 04:04

Under the assumption that your JavaScript code is code on your pages and not code on your server, then no, there's no API provided for JavaScript in a web browser other than a server-side API accessible via HTTP that you would create yourself. If the directory full of files is on the server, then it's going to have to be some server-side code that delivers the directory listing anyway. You could write such code in the server-side programming environment of your choice (including a server-side JavaScript solution, if that's what you want and if such a thing is possible at your ISP). As Pekka notes, it may be possible to simply enable directory browsing in your server, though that's generally a fairly low-level service that will deliver some sort of HTML page to you, and parsing through that might be somewhat painful (compared to what you could get from a tailor-made service).

Another, simpler thing you could do would be to upload a manifest file along with the other image files. In other words, create the directory listing in some easy-to-digest form, and maintain it separately as a simple file to be fetched.

查看更多
叛逆
3楼-- · 2019-07-30 04:16

javascript not suport directory listing in a direct way. but you can create a directory dumper php file, and send via AJAX.

查看更多
登录 后发表回答