我为nodejs图像上传做了一个教程。
问题:nodejs把上传的图片存放在哪里?
我在本地工作 mit localhost:8888 (我是 nodejs 和编程的新手)
requestHandler.upload = function( response, request ) {
console.log( "Request for 'upload' is called." );
var form = new formidable.IncomingForm();
console.log( "Preparing upload" );
form.parse( request, function( error, fields, files ){
console.log( "Completed Parsing" );
if( error ){
response.writeHead( 500, { "Content-Type" : "text/plain" } );
response.end( "CRAP! " + error + "\n" );
return;
}
console.log("the path is: " +files.upload.path);
fs.renameSync( files.upload.path, "/tmp/" + files.upload.name );
response.writeHead( 200, { "Content-Type" : "text/html" } );
response.write( "received image <br />" );
response.end( "<img src='/show?i=" + files.upload.name + "' />" );
});
};