Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
48 lines (43 loc) · 1.46 KB

File metadata and controls

48 lines (43 loc) · 1.46 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* Created with JetBrains WebStorm.
* User: cwwu
* Date: 13-7-17
* Time: 下午5:34
* To change this template use File | Settings | File Templates.
*/
var fileUtils = require('../utils/file.js');
var configInfo = require('../config.js');
var root=configInfo.root+"/public/upload";
var url=require("url"),
path=require("path"),
util=require('util'),
fs=require("fs");
exports.initFileInfo=function (req,res,next){
console.log(url.parse(req.url).pathname);
//将url地址的中的%20替换为空格,不然Node.js找不到文件
var filePath= fileUtils.urlParse(req);
if(filePath=='/'){
fileUtils.listDirectory(root,req,res);
}else{
var filename=path.join(root,filePath);
path.exists(filename,function(exists){
if(!exists){
util.error('找不到文件'+filename);
res.redirect("404.html");
}else{
fs.stat(filename,function(err,stat){
if(stat.isFile()){
fileUtils.showFile(filename,req,res);
}else if(stat.isDirectory()){
fileUtils.listDirectory(filename,req,res);
}
});
}
});
}
};
exports.initPdf = function (req,res,next){
var fileUrl = req.url.split("url=")[1];
console.log("fileUrl"+fileUrl);
res.render('./file/pdfBrowser.html',{url:fileUrl});
};
Morty Proxy This is a proxified and sanitized view of the page, visit original site.