View Full Version : Uploading files programatically

4 Apr 2011, 4:42 PM
I'm hoping this isn't a FAQ. What I need to do is encode a data structure as JSON and send it to a server using POST as if it were an uploaded file. That is, I'd like take this kind of HTML fragment:

<form name="resourcepost" method=post enctype="multipart/form-data" action="http://server/destpath">
<input type=file name="datafile" accept="application/json" size=120>
<input type="submit" value="Post"/>

... but have Ext create the file contents and post it instead. Something like this, I assume:

url: postPath,
method: 'POST'

But in this case, what do I do with jsonContent, and how would I specify the name of the uploaded file (fx. 'data.json')?