简体   繁体   English

上载图片parse.com

[英]Upload an image parse.com

I am trying to upload an imagen but when i save the information I can saw the image.Can you help me? 我正在尝试上传图像,但是当我保存信息时,我可以看到图像。您能帮我吗?

            <!-- 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>

I have this input and 我有这个输入

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");
        });

I use the javascript guide but i dont know what i miss 我使用JavaScript指南,但我不知道自己想念什么

You should try with var url = req.body.imagen.path; 您应该尝试使用var url = req.body.imagen.path; or var url = req.files.imagen.path; var url = req.files.imagen.path; .

You forgot .path for your url variable. 您忘记了.path作为您的url变量。 imagen is an object containing various informations about the uploaded file (path for tmp folder, name, size...). imagen是一个对象,其中包含有关上载文件的各种信息(tmp文件夹的路径,名称,大小...)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM