JQuery 文件上传中间件 - 未创建图像版本
JQuery File Upload middleware - Image versions not creating
我已按照简单 usage example:
中所述配置了我的 jquery-file-upload-middleware
// configure upload middleware
upload.configure({
uploadDir: './public/uploads',
uploadUrl: '/uploads',
imageVersions: {
thumbs: {
width: 80,
height: 80
}
}
});
图片上传成功,文件夹thumbs已创建,但里面没有文件。我尝试添加其他图像版本,但问题仍然存在。
使用jquery-file-upload-middleware v0.1.5, node v4.1.0 and express v4.13.3.
我是否遗漏了一些额外的设置?
有两处可能是错误的
1) 您无法写入您的临时 (tmp) 目录
您没有在配置中指定 tmpDir
,因此它正在寻找 /tmp
您可以指定一个,例如 tmpDir : __dirname + '/public/tmp',
所以你的配置变成
upload.configure({
tmpDir : __dirname + '/public/tmp',
uploadDir: './public/uploads',
//etc...
});
2) 您需要确保安装了 ImageMagick
查看此问题了解更多信息https://github.com/aguidrevitch/jquery-file-upload-middleware/issues/34
您可以从这里下载 ImageMagick 二进制文件
Link
编辑
需要添加一些日志记录。
看这里
https://github.com/aguidrevitch/jquery-file-upload-middleware
添加这个:
upload.on('error', function (e, req, res) {
console.log(e.message);
});
...如果有任何错误,这应该会告诉您(通过输出到控制台)。
我已按照简单 usage example:
中所述配置了我的jquery-file-upload-middleware
// configure upload middleware
upload.configure({
uploadDir: './public/uploads',
uploadUrl: '/uploads',
imageVersions: {
thumbs: {
width: 80,
height: 80
}
}
});
图片上传成功,文件夹thumbs已创建,但里面没有文件。我尝试添加其他图像版本,但问题仍然存在。
使用jquery-file-upload-middleware v0.1.5, node v4.1.0 and express v4.13.3.
我是否遗漏了一些额外的设置?
有两处可能是错误的
1) 您无法写入您的临时 (tmp) 目录
您没有在配置中指定 tmpDir
,因此它正在寻找 /tmp
您可以指定一个,例如 tmpDir : __dirname + '/public/tmp',
所以你的配置变成
upload.configure({
tmpDir : __dirname + '/public/tmp',
uploadDir: './public/uploads',
//etc...
});
2) 您需要确保安装了 ImageMagick
查看此问题了解更多信息https://github.com/aguidrevitch/jquery-file-upload-middleware/issues/34
您可以从这里下载 ImageMagick 二进制文件 Link
编辑
需要添加一些日志记录。
看这里
https://github.com/aguidrevitch/jquery-file-upload-middleware
添加这个:
upload.on('error', function (e, req, res) {
console.log(e.message);
});
...如果有任何错误,这应该会告诉您(通过输出到控制台)。