<! DOCTYPE html>//base64 transcoding function functionBase64 (file, callback) {varCoolfile = {}; functionReaderonload (e) {varBase64 =Btoa (E.target.result); Coolfile.base64=base64; Callback (Coolfile)}; varReader =NewFileReader (); Reader.onload=Readeronload; varFile = File[0].files[0]; Coolfile.filetype=File.type; Coolfile.size=file.size; Coolfile.filename=File.name; reader.readasbinarystring (file); } functionAA () {//var preview = document.queryselector (' img '); //var file = document.queryselector (' #files '). Files[0]; varName = $ (' #files '). Val (); Base64 ($ (' Input[type= ' (file "] '),function(data) {//Console.log (data.base64) vardata = { "File":{ "File":d ata.base64,"FileName": Name,"FilePath": "public://" +name}}; Options={type:"POST", Data:data, url:"Http://demo.dd:8083/userapi/app_services/UploadFile", DataType:' JSON ', Success:function(Result) {Console.log (json.stringify (result)); } }; $.ajax (options); }) } </script>Use JavaScript to turn a picture into a base64 bit encoding and then transfer it to the server (the interface of the AJAX call is based on DRUPA7)