JavaScript ---- 파일을 다운로드 할 때 백그라운드에서 전달 된 파일 이름 값을 가져 오는 방법

1. 첫 번째 방법

downloadTitle = md.headers ( 'content-disposition'). split ( ';') [1] .split ( '=') [1]; 
downloadTitle = decodeURI (downloadTitle);

2. 두 번째 방법

const disposition = res.headers [ "content-disposition"] 
const filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/; 
const 일치 = filenameRegex.exec (disposition); 
const 파일 이름 = 일치 [1] .replace (/ [ ' "] / g,' ');


추천

출처blog.51cto.com/dd118/2551181