javascript - How can I make a webpage check to see if a link file has the wrong file type to check for another file type? -


i making webpage going have large amount of word documents linked on review. formatting word lists of files reviewed html page , use macro generate links files reviewed. macro generates links linked .doc files. company starting moving word 2010, users still using word 2003, have files being submitted in .doc format , being submitted in .docx format. looking way in asp, asp.net, or javascript have the webpage see if file not on server in .doc file format check see if there exists file sane file name in .docx file format. suggestions appreciated.

you should checking on server side.

assuming use vb.net , files being kept in same directory following code might you:

dim strrequest string = request.querystring("file") if strrequest <> ""    dim path string = server.mappath(strrequest)   dim docxpath string = system.io.path.changeextension(path, ".docx")   dim file system.io.fileinfo = new system.io.fileinfo(docxpath)    if file.exists 'set appropriate headers     response.clear()     response.addheader("content-disposition", "attachment; filename=" & file.name)     response.addheader("content-length", file.length.tostring())     response.contenttype = "application/octet-stream"     response.writefile(file.fullname)     response.end    else     ' same original path 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -