我正在尝试上传图片,但是当我保存信息时,我可以看到图片。你可以帮帮我吗?
<!-- file-->
<div class="form-group">
<label class="col-md-4 control-label" for="">Foto</label>
<div class="col-md-8">
<input id="imagen" name="imagen" class="form-control input-md" type="file">
</div>
</div>
我有这个输入和
var bytes = [ 0xBE, 0xEF, 0xCA, 0xFE ];
var url = req.body.imagen;
var file = new Parse.File(url, bytes);
file.save().then(function() {
alert("Save");
}, function(error) {
alert("Fail");
});
我使用javascript指南,但我不知道我想念的是什么
答案 0 :(得分:1)
您应该尝试'use strict';
var watson = require('watson-developer-cloud');
var fs = require('fs');
var speech_to_text = watson.speech_to_text({
username: '{username}',
password: '{password}',
version: 'v1',
url: 'https://stream.watsonplatform.net/speech-to-text-beta/api'
});
var params = {
content_type: 'audio/wav',
};
// create the stream
var recognizeStream = speech_to_text.createRecognizeStream(params);
// // pipe in some audio
fs.createReadStream(__dirname + '/resources/speech.wav').pipe(recognizeStream);
// // and pipe out the transcription
recognizeStream.pipe(fs.createWriteStream('transcription.txt'));
// listen for 'data' events for just the final text
// listen for 'results' events to get the raw JSON with interim results, timings, etc.
recognizeStream.setEncoding('utf8'); // to get strings instead of Buffers from `data` events
['data', 'results', 'error', 'connection-close'].forEach(function(eventName) {
recognizeStream.on(eventName, console.log.bind(console, eventName + ' event: '));
});
或var url = req.body.imagen.path;
。
您忘记了var url = req.files.imagen.path;
变量.path
。 url
是一个对象,包含有关上传文件的各种信息(tmp文件夹的路径,名称,大小......)。