Extjs File upload using json service?

2019-04-15 23:31发布

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?

2条回答
Bombasti
2楼-- · 2019-04-15 23:39

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/

查看更多
你好瞎i
3楼-- · 2019-04-15 23:51

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

查看更多
登录 后发表回答