Extjs File upload using json service?

青春壹個敷衍的年華 提交于 2019-12-06 12:41:34

问题


I am using json service(.net RIA service) to push data to server from Extjs. Currently I have a requirement to upload document to server. I saw some examples using form submit to php files.

Is this possible through json service? or Is it necessery to create some server logic where i can accept form submits?

Is it possible to read some binary data from client side and push as json data to server?


回答1:


In Extjs, File uploads are not performed using normal 'Ajax' techniques, that is they are not performed using XMLHttpRequests. Instead a hidden element containing all the fields is created temporarily and submitted with its target set to refer to a dynamically generated, hidden which is inserted into the document but removed after the return data has been gathered.

Be aware that file upload packets are sent with the content type multipart/form and some server technologies

check : http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.Basic-method-hasUpload




回答2:


Yes it's possible. You should use FileReader to get binary base64 encoded content (FileReader.readAsDataURL(Blob|File)), which you can transfer with JSON.

More insights here: http://www.html5rocks.com/en/tutorials/file/dndfiles/



来源:https://stackoverflow.com/questions/13125148/extjs-file-upload-using-json-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!