简体   繁体   中英

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

You should try with var url = req.body.imagen.path; or var url = req.files.imagen.path; .

You forgot .path for your url variable. imagen is an object containing various informations about the uploaded file (path for tmp folder, name, size...).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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