0

I have some images on my server folder and I would like to know is there a way to get that folder path and the filenames of images in that folder.

How do I access them?

This is how my folder structure looks like:

enter image description here

I understood that its a security issue and so I would like to know that I have done that using server side code but I would like to get that folder from codebehind to jquery. Is that possible?

This is how I am trying to create a folder on my server and this can be retrieved using jquery:

IO.Directory.CreateDirectory(Server.MapPath("Uploads/" & tempDir))

2 Answers 2

1

You would have to output them in the page you are rendering.

So first you would need to build a collection of files on the server, then output that list on the page, perhaps in to a hidden field. You could then read this field using JavaScript.

Another alternative would be to enable directory browsing in IIS and then performing a GET request on that directory.

Sign up to request clarification or add additional context in comments.

2 Comments

@Vince-I have updated my code can you check that and say me if it is possible?
You need to go in to IIS and enable "Directory Browsing" for that particular directory. Then using your favorite client side framework, i.e. jQuery, perform a GET request on that directory and you should get a listing. Be very careful if doing so, you don't want to expose any files that could be compromised.
1

You can't access your computers' files and directories from Javascript. This is a security issue. You need to use a server side language.

EDIT: Unless you use node.js

4 Comments

@elclanrs-I have updated my code can you check that and say me if it is possible?
Oh, I understand now, lol. Well, I'm not that familiar with ASP, but my guess is that you'll need get those variables in the front-end with ajax somehow...
@elclarns-Yes,I was trying to get that :)
You can output a list of files and their paths using a Hidden field, then read it in using JS and simulate remote directory browsing. Provided the directory is mapped to a virtual path, it is possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.