Skip to content

Instantly share code, notes, and snippets.

View dileephell's full-sized avatar
🎯
Focusing

Dileep Singh dileephell

🎯
Focusing
View GitHub Profile
var tmp_path = req.files.uploadimgs.path,uuid;
var target_path = './upload/work/'+uuid() +'.png';
if(req.files)
{
mkdirp(newDir,0777,function(err){
if(err) throw err;
})
}
if(req.files)
var uuid=require('node-uuid');
var tmp_path = req.files.uploadimgs.path,uuid;
console.log(uuid);
// set where the file should actually exists - in this case it is in the "images" directory
var target_path = './upload/work/' +req.files.uploadimgs.name+uuid();
// move the file from the temporary location to the intended location
fs.rename(tmp_path, target_path, function(err) {
if (err) throw err;
console.log('cfgh');
// delete the temporary file, so that the explicitly set temporary upload dir does not get filled with unwanted files
var tmp_path = req.files.uploadimgs.path;
// set where the file should actually exists - in this case it is in the "images" directory
var target_path = './upload/work/' + req.files.uploadimgs.name;
// move the file from the temporary location to the intended location
fs.rename(tmp_path, target_path, function(err) {
if (err) throw err;
console.log('cfgh');
// delete the temporary file, so that the explicitly set temporary upload dir does not get filled with unwanted files
fs.unlink(tmp_path, function() {
if (err) throw err;
Error: .get() requires callback functions but got a [object Undefined]
at Router.route.Route.sensitive (/home/dileep/node_modules/express/lib/router/index.js:252:11)
at Array.forEach (native)
at Router.route (/home/dileep/node_modules/express/lib/router/index.js:248:13)
at Router.methods.forEach.Router.(anonymous function) [as get] (/home/dileep/node_modules/express/lib/router/index.js:270:16)
at Function.methods.forEach.app.(anonymous function) [as get] (/home/dileep/node_modules/express/lib/application.js:412:26)
at Object.<anonymous> (/home/dileep/workspace/erp/app.js:25:5)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
@dileephell
dileephell / gist:4214933
Created December 5, 2012 11:42 — forked from anonymous/gist:4214908
dileep
var express = require('express')
, app = express()
, fs = require('fs');
// Routes
app.get('/form', function(req, res)
{
fs.readFile('./form.html', function(error, content)
{
var express = require('express')
, app = express()
, fs = require('fs');
// Routes
app.get('/form', function(req, res)
{
fs.readFile('./form.html', function(error, content)
{
var db = require('../lib/db');
var UserSchema = new db.Schema({
username : {type: String, unique: true}
, password : String
})
var MyUser = db.mongoose.model('User', UserSchema);
// Exports
module.exports.addUser = addUser;
// Add user to database
function addUser(username, password, callback) {
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
module.exports.mongoose = mongoose;
module.exports.Schema = Schema;
//Connect to cloud database
var username = "Dileep"
var password ="******";
@dileephell
dileephell / gist:4085325
Created November 16, 2012 08:03
dileep css
var http = require('http');
var querystring = require('querystring');
var util = require('util');
http.createServer(function (req, res) {
// set up some routes
switch(req.url) {
case '/':
// show the user a simple form
console.log("[200] " + req.method + " to " + req.url);
@dileephell
dileephell / gist:4084576
Created November 16, 2012 05:53
dileep form
var http = require('http');
http.createServer(function (req, res) {
// set up some routes
switch(req.url) {
case '/':
// show the user a simple form
console.log("[200] " + req.method + " to " + req.url);
res.writeHead(200, "OK", {'Content-Type': 'text/html'});
res.write('<html><head><link rel="stylesheet" type="text/css" href="style.css"><title>Hello Noder!</title></head><body>');