1

我正在尝试使用下面的代码将图像上传到服务器。它适用于高达 ~70KB 的小图像。

对于较大的图像,它将文件状态设置为cancelled,保存到服务器磁盘,但大小为零 KB

var CustomerController = {

  uploadPhoto: function (request, response) {

    var customerId = request.param('id');

    // check for the existence of the customer

    Customer.findOne({
      id: customerId
    }).exec(function (err, customer) {

      if (err || !customer) {
        return response.notFound('Customer not found');
      }

      // get the file that was uploaded from the client
      // and save it to disk

      request.file('photo').upload(function onUploadComplete(err, files) {

        if (err || !files || files.length < 1)
          return response.serverError('Error uploading photo: ' + err);

        // do something with files here

      });


    });


  },

  _config: {}

};

module.exports = CustomerController;

我正在使用 Sails 0.10.0-rc7。

有任何想法吗?

4

0 回答 0