0
I have a folder with several pdf files and needed to select the pdf 1348.pdf, but via javascript, is it possible to do this ? Would I have to use an Handler ? and how would I return this value (Binary,name and size) ?
~/files/1348.pdf
In a server method would look like this:
DirectoryInfo diretorio = new DirectoryInfo(Server.MapPath("~/arquivos/"));
FileInfo[] arquivos = diretorio.GetFiles("1348.pdf");
I wanted to know how to do this via javascript
Explain better what you want with examples of preference
– Rafael Augusto
@Rafaelaugusto put an example code that would be needed on the server for javascript but I do not know if it is possible.
– Voltz
What you intend to do with the selection of this file?
– Rafael Augusto
If the files are on the server you need some server-side script (.net, php and etc) or you can even do "only" with javascript... but you need to be able to configure the server so that it allows Browse access of content directly to the directory.
– Leandro Angelo
@Rafaelaugusto I made a screen that loads the data via javascript without going to the database and I include a pdf file per data if the user wishes, but when I load the page the other day and have the data there I need to load this pdf, so that he knows he has a file there and/or if he wants to delete it, then basically to show the name to the user and store it in fileupload and then delete if the client wants.
– Voltz
@Leandroangelo ok so basically I will need to use an ajax method that sends the parameters as "file name" and in Handler I select the file, but how would I return this file to ajax? context.Response.Write(file) ?
– Voltz
Sorry, @Voltz, but it’s still a little confused what you intend to do. You want to view the pdf on a web page, download the file or display on the screen the list of files you have in this directory?
– Leandro Angelo
@Leandroangelo If I can list them all via javascript I think I can already follow with my problem
– Voltz
@Leandroangelo I just need to get the files so I can delete them, all this via javascript/webmethod/Handler
– Voltz