praks5432
praks5432

Reputation: 7792

node.js files.upload.path is undefined

I'm working through the node beginner book and I'm at the final step. At this code:

var form = new formidable.IncomingForm();
form.parse(request,function(error,fields,files){
    fs.rename(files.upload.path,"/tmp/test.png",function(error){
        if(error){
            fs.unlink("/tmp/test.png");
            fs.rename(files.upload.path,"/tmp/test.png");
        }

    });
});

terminal tells me that files.upload is undefined - I'm not sure why - can anyone tell me?

Upvotes: 0

Views: 1466

Answers (2)

Brad
Brad

Reputation: 1

I'm guessing you are on a windows machine. His examples are on Linux. I fixed it by changing the path to "/Users/[USER]/AppData/Local/Temp/test.png" (in all places the other path is used)

Upvotes: 0

Ari Firmanto
Ari Firmanto

Reputation: 344

i have same issue too. I fixed by delete request.setEncoding("utf8") on server.js

Upvotes: 1

Related Questions