1
我有一个场景:我使用一些服务器位置上传一个文件:https://www.playframework.com/documentation/2.0/JavaFileUpload,如何使用Play Framework和jQuery上传和显示文件?
//上传文件:
<input type="file" name="fileUpload">
<input type="submit" value="Upload">
而且从下面的代码,我上传上述上传的文件和越来越/我查看页面上显示它像(点击提交按钮后):
<input type="file" id="inputfile">
<input type="button" value="Submit" id="submitfile">
的jQuery:
$("#submitfile").click(function(){
var path1 =$('input[type=file]').val().replace(/C:\\fakepath\\/i, '');//uploaded file names
//adding the Play framework server path for Application to get the image(s) file(s) path
var filespath = '/files/images/'+path1;//giving my uploaded files path here
});
但我的要求是:我只需要一种类型,既可以接受/上传服务器位置的文件,并返回/显示从我的查看页面上的服务器位置相同的文件路径?我正在努力。请帮帮我。
我得到内部服务器错误 – Dhana
我们可以像上面这样实现它:http://stackoverflow.com/questions/33209460/how-to-redirect-to-same-overlay-on-return-statement-in-play-框架 – Dhana
哦,抱歉哈哈。我没有意识到你发布了我引用的问题。编辑我的答案根据[2320069](http://stackoverflow.com/questions/2320069/jquery-ajax-file-upload),[20452853](http://stackoverflow.com/questions/20452853/uploading-files-通过jQuery的对象形式数据是提供和无文件名称获得重新),[6974684](http://stackoverflow.com/questions/6974684/how-to-send-formdata-objects -with-ajax-requests-in-jquery)其中说你需要在发送之前将你的文件存储到ajax formData对象中,或者采取另一种方法 – Chrizt0f