Skip to main content
edited tags
Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238
Tweeted twitter.com/#!/StackCodeReview/status/163946971181236225
improved formatting
Source Link
palacsint
  • 30.4k
  • 9
  • 82
  • 157

Looking for feedback on JS techniques JavaScript/PHP file uploader

I'm writing a javascriptJavaScript/phpPHP file uploader and I want to start this project off on the right track. I've started with this, a js UploaderJavaScript Uploader object which will handle ajaxAjax calls, display progress, show error messages, etc. I'm just hoping to get some feedback on the way I'm setting up my scripts. Thank you in advance!

function Uploader(method) {

if(arguments.callee._singleton) return arguments.callee._singleton;
var _this = arguments.callee._singleton = this;

_this.opts = {
    form:"#uploader",
    filePath:"public/uploads/",
    errorCodes:{
        1:"No file/folder selected",
        2:"Invalid file/folder type",
        3:"File/folder exceeds upload size"
    }   
}

_this.methods = {
    
    init: function(options) {
        for(var o in options) {
            _this.opts[o] = options[o];
        }
        
        _this.methods.setup();
    },
    
    setup: function() {
        
    }
    
}   

if(_this.methods[method]) return _this.methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
else if(typeof method === "object" || !method) return methods.init.apply(this, arguments);

}

Looking for feedback on JS techniques

I'm writing a javascript/php file uploader and I want to start this project off on the right track. I've started with this, a js Uploader object which will handle ajax calls, display progress, show error messages, etc. I'm just hoping to get some feedback on the way I'm setting up my scripts. Thank you in advance!

function Uploader(method) {

if(arguments.callee._singleton) return arguments.callee._singleton;
var _this = arguments.callee._singleton = this;

_this.opts = {
    form:"#uploader",
    filePath:"public/uploads/",
    errorCodes:{
        1:"No file/folder selected",
        2:"Invalid file/folder type",
        3:"File/folder exceeds upload size"
    }   
}

_this.methods = {
    
    init: function(options) {
        for(var o in options) {
            _this.opts[o] = options[o];
        }
        
        _this.methods.setup();
    },
    
    setup: function() {
        
    }
    
}   

if(_this.methods[method]) return _this.methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
else if(typeof method === "object" || !method) return methods.init.apply(this, arguments);

}

JavaScript/PHP file uploader

I'm writing a JavaScript/PHP file uploader and I want to start this project off on the right track. I've started with this, a JavaScript Uploader object which will handle Ajax calls, display progress, show error messages, etc. I'm just hoping to get some feedback on the way I'm setting up my scripts.

function Uploader(method) {

if(arguments.callee._singleton) return arguments.callee._singleton;
var _this = arguments.callee._singleton = this;

_this.opts = {
    form:"#uploader",
    filePath:"public/uploads/",
    errorCodes:{
        1:"No file/folder selected",
        2:"Invalid file/folder type",
        3:"File/folder exceeds upload size"
    }   
}

_this.methods = {
    
    init: function(options) {
        for(var o in options) {
            _this.opts[o] = options[o];
        }
        
        _this.methods.setup();
    },
    
    setup: function() {
        
    }
    
}   

if(_this.methods[method]) return _this.methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
else if(typeof method === "object" || !method) return methods.init.apply(this, arguments);

}
Source Link
Jbird
  • 31
  • 1

Looking for feedback on JS techniques

I'm writing a javascript/php file uploader and I want to start this project off on the right track. I've started with this, a js Uploader object which will handle ajax calls, display progress, show error messages, etc. I'm just hoping to get some feedback on the way I'm setting up my scripts. Thank you in advance!

function Uploader(method) {

if(arguments.callee._singleton) return arguments.callee._singleton;
var _this = arguments.callee._singleton = this;

_this.opts = {
    form:"#uploader",
    filePath:"public/uploads/",
    errorCodes:{
        1:"No file/folder selected",
        2:"Invalid file/folder type",
        3:"File/folder exceeds upload size"
    }   
}

_this.methods = {
    
    init: function(options) {
        for(var o in options) {
            _this.opts[o] = options[o];
        }
        
        _this.methods.setup();
    },
    
    setup: function() {
        
    }
    
}   

if(_this.methods[method]) return _this.methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
else if(typeof method === "object" || !method) return methods.init.apply(this, arguments);

}