|
1 | 1 | #!/usr/bin/env node
|
2 | 2 | /*
|
3 |
| - * jQuery File Upload Plugin Node.js Example 1.0.1 |
| 3 | + * jQuery File Upload Plugin Node.js Example 1.0.2 |
4 | 4 | * https://github.com/blueimp/jQuery-File-Upload
|
5 | 5 | *
|
6 | 6 | * Copyright 2012, Sebastian Tschan
|
|
10 | 10 | * http://www.opensource.org/licenses/MIT
|
11 | 11 | */
|
12 | 12 |
|
13 |
| -/*jslint nomen: true, regexp: true */ |
| 13 | +/*jslint nomen: true, regexp: true, unparam: true */ |
14 | 14 | /*global require, __dirname, unescape */
|
15 | 15 |
|
16 | 16 | (function (port) {
|
17 | 17 | 'use strict';
|
18 |
| - var util = require('util'), |
19 |
| - path = require('path'), |
| 18 | + var path = require('path'), |
20 | 19 | fs = require('fs'),
|
| 20 | + // Since Node 0.8, .existsSync() moved from path to fs: |
| 21 | + _existsSync = fs.existsSync || path.existsSync, |
21 | 22 | formidable = require('formidable'),
|
22 | 23 | nodeStatic = require('node-static'),
|
23 | 24 | imageMagick = require('imagemagick'),
|
|
163 | 164 | // Prevent directory traversal and creating hidden system files:
|
164 | 165 | this.name = path.basename(this.name).replace(/^\.+/, '');
|
165 | 166 | // Prevent overwriting existing files:
|
166 |
| - while (path.existsSync(options.uploadDir + '/' + this.name)) { |
| 167 | + while (_existsSync(options.uploadDir + '/' + this.name)) { |
167 | 168 | this.name = this.name.replace(nameCountRegexp, nameCountFunc);
|
168 | 169 | }
|
169 | 170 | };
|
|
174 | 175 | '//' + req.headers.host + options.uploadUrl;
|
175 | 176 | this.url = this.delete_url = baseUrl + encodeURIComponent(this.name);
|
176 | 177 | Object.keys(options.imageVersions).forEach(function (version) {
|
177 |
| - if (path.existsSync( |
| 178 | + if (_existsSync( |
178 | 179 | options.uploadDir + '/' + version + '/' + that.name
|
179 | 180 | )) {
|
180 | 181 | that[version + '_url'] = baseUrl + version + '/' +
|
|
281 | 282 | } else {
|
282 | 283 | require('http').createServer(serve).listen(port);
|
283 | 284 | }
|
284 |
| -}(8080)); |
| 285 | +}(8888)); |
0 commit comments