I would like to list the files in the form of a link (to click on download).
List the directory files below the upload input
Ajax:
functionCarregaArquivos(Id){$.ajax({url:"/Qualidade/RiscoAcao/ListarArquivos",
data: { IdAcao: Id },
async: false,
success: function (data) {
$.each(data, function (i, element) {
console.log(data);
});
}
});
}
C #:
//Retornar todos os arquivos de um diretório:
public ActionResult ListarArquivos(int IdAcao)
{
#if DEBUG
//Verifica se existe uma pasta com o nome do Id (para salvar dentro dela)
string caminhoDiretorio = @"//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/" + IdAcao;
#else
//Verifica se existe uma pasta com o nome do Id (para salvar dentro dela)
string caminhoDiretorio = @"//fileserver/repositorio$/DiagramaProcesso/Producao/AcaoRisco/"+ IdAcao;
#endif
string[] arquivos = new string[] { };
if (Directory.Exists(caminhoDiretorio)) // se existe
{
arquivos = Directory.GetFiles(caminhoDiretorio);
}
return Json(arquivos, JsonRequestBehavior.AllowGet);
}
Return (Console.log):
(5) ["//fileserver/repositorio$/DiagramaProcesso/Teste/A…oRisco/107930383d208c14c9429828a041b8eeabb.jpg", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (1).pdf", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (2).pdf", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList.pdf", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\EmailHandler.zip"]0: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/107930383d208c14c9429828a041b8eeabb.jpg"1: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (1).pdf"2: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (2).pdf"3: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList.pdf"4: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\EmailHandler.zip"length: 5__proto__: Array(0)concat: ƒ concat()constructor: ƒ Array()copyWithin: ƒ copyWithin()entries: ƒ entries()every: ƒ every()fill: ƒ fill()filter: ƒ filter()find: ƒ find()findIndex: ƒ findIndex()forEach: ƒ forEach()includes: ƒ includes()indexOf: ƒ indexOf()join: ƒ join()keys: ƒ keys()lastIndexOf: ƒ lastIndexOf()length: 0map: ƒ map()pop: ƒ pop()push: ƒ push()reduce: ƒ reduce()reduceRight: ƒ reduceRight()reverse: ƒ reverse()shift: ƒ shift()slice: ƒ slice()some: ƒ some()sort: ƒ sort()splice: ƒ splice()toLocaleString: ƒ toLocaleString()toString: ƒ toString()unshift: ƒ unshift()values: ƒ values()Symbol(Symbol.iterator): ƒ values()Symbol(Symbol.unscopables): {copyWithin: true, entries: true, fill: true, find: true, findIndex: true, …}__proto__: Object
riscolista.js:388 (5) ["//fileserver/repositorio$/DiagramaProcesso/Teste/A…oRisco/107930383d208c14c9429828a041b8eeabb.jpg", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (1).pdf", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (2).pdf", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList.pdf", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\EmailHandler.zip"]0: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/107930383d208c14c9429828a041b8eeabb.jpg"1: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (1).pdf"2: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (2).pdf"3: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList.pdf"4: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\EmailHandler.zip"length: 5__proto__: Array(0)concat: ƒ concat()constructor: ƒ Array()copyWithin: ƒ copyWithin()entries: ƒ entries()every: ƒ every()fill: ƒ fill()filter: ƒ filter()find: ƒ find()findIndex: ƒ findIndex()forEach: ƒ forEach()includes: ƒ includes()indexOf: ƒ indexOf()join: ƒ join()keys: ƒ keys()lastIndexOf: ƒ lastIndexOf()length: 0map: ƒ map()pop: ƒ pop()push: ƒ push()reduce: ƒ reduce()reduceRight: ƒ reduceRight()reverse: ƒ reverse()shift: ƒ shift()slice: ƒ slice()some: ƒ some()sort: ƒ sort()splice: ƒ splice()toLocaleString: ƒ toLocaleString()toString: ƒ toString()unshift: ƒ unshift()values: ƒ values()Symbol(Symbol.iterator): ƒ values()Symbol(Symbol.unscopables): {copyWithin: true, entries: true, fill: true, find: true, findIndex: true, …}__proto__: Object
riscolista.js:388 (5) ["//fileserver/repositorio$/DiagramaProcesso/Teste/A…oRisco/107930383d208c14c9429828a041b8eeabb.jpg", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (1).pdf", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (2).pdf", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList.pdf", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\EmailHandler.zip"]0: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/107930383d208c14c9429828a041b8eeabb.jpg"1: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (1).pdf"2: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (2).pdf"3: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList.pdf"4: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\EmailHandler.zip"length: 5__proto__: Array(0)
riscolista.js:388 (5) ["//fileserver/repositorio$/DiagramaProcesso/Teste/A…oRisco/107930383d208c14c9429828a041b8eeabb.jpg", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (1).pdf", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (2).pdf", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList.pdf", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\EmailHandler.zip"]0: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/107930383d208c14c9429828a041b8eeabb.jpg"1: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (1).pdf"2: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (2).pdf"3: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList.pdf"4: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\EmailHandler.zip"length: 5__proto__: Array(0)concat: ƒ concat()constructor: ƒ Array()copyWithin: ƒ copyWithin()entries: ƒ entries()every: ƒ every()fill: ƒ fill()filter: ƒ filter()find: ƒ find()findIndex: ƒ findIndex()forEach: ƒ forEach()includes: ƒ includes()indexOf: ƒ indexOf()join: ƒ join()keys: ƒ keys()lastIndexOf: ƒ lastIndexOf()length: 0map: ƒ map()pop: ƒ pop()push: ƒ push()reduce: ƒ reduce()reduceRight: ƒ reduceRight()reverse: ƒ reverse()shift: ƒ shift()slice: ƒ slice()some: ƒ some()sort: ƒ sort()splice: ƒ splice()toLocaleString: ƒ toLocaleString()toString: ƒ toString()unshift: ƒ unshift()values: ƒ values()Symbol(Symbol.iterator): ƒ values()Symbol(Symbol.unscopables): {copyWithin: true, entries: true, fill: true, find: true, findIndex: true, …}__proto__: Object
riscolista.js:388 (5) ["//fileserver/repositorio$/DiagramaProcesso/Teste/A…oRisco/107930383d208c14c9429828a041b8eeabb.jpg", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (1).pdf", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (2).pdf", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList.pdf", "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\EmailHandler.zip"]0: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/107930383d208c14c9429828a041b8eeabb.jpg"1: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (1).pdf"2: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList (2).pdf"3: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\CustomerList.pdf"4: "//fileserver/repositorio$/DiagramaProcesso/Teste/AcaoRisco/10793\EmailHandler.zip"length: 5__proto__: Array(0)concat: ƒ concat()constructor: ƒ Array()copyWithin: ƒ copyWithin()entries: ƒ entries()every: ƒ every()fill: ƒ fill()filter: ƒ filter()find: ƒ find()findIndex: ƒ findIndex()forEach: ƒ forEach()includes: ƒ includes()indexOf: ƒ indexOf()join: ƒ join()keys: ƒ keys()lastIndexOf: ƒ lastIndexOf()length: 0map: ƒ map()pop: ƒ pop()push: ƒ push()reduce: ƒ reduce()reduceRight: ƒ reduceRight()reverse: ƒ reverse()shift: ƒ shift()slice: ƒ slice()some: ƒ some()sort: ƒ sort()splice: ƒ splice()toLocaleString: ƒ toLocaleString()toString: ƒ toString()unshift: ƒ unshift()values: ƒ values()Symbol(Symbol.iterator): ƒ values()Symbol(Symbol.unscopables): {copyWithin: true, entries: true, fill: true, find: true, findIndex: true, …}__proto__: Object