2

I was looking at what my own server accepts, and it is looking for JSON files, which i double checked with my colleagues and confirmed.

My question is this:

If I have a Javascript object, and need to sent it to the server as a file? How would that be done? I was thinking that I would need to use a hidden iframe or something and then submit it.

I was hoping there was some way to say:

var _JS_OBJ_ = {/* ... */}
var f = File(JSON.stringify(_JS_OBJ_));
// ...
// submit a multipart form -OR- $.ajax({.....});

I was hoping there was a way to create a virtual file which isnt actually saved to the client machine, which would alleviate the client-server file downloading restrictions. That way since it isnt saved, i could create a dynamic file to upload to a server via a AJAX call.

22
  • stackoverflow.com/questions/6255344/… Commented Aug 12, 2013 at 16:43
  • I know how JSON works, and do that all the time, but the servers accept JSON FILES, not JSON objects.... So i was thinking that i would need to create a temp file, store a string in there, and then post that file to the server. Commented Aug 12, 2013 at 16:48
  • stackoverflow.com/questions/5587973/javascript-upload-file Commented Aug 12, 2013 at 16:49
  • @Fallenreaper Incorrect. The server accepts a long string of 1's and 0's -- that at a slightly higher level is checked to be a string representing a JSON object. If it wants to save those on the disk drive as part of the file system, that is the server's business. Commented Aug 12, 2013 at 16:51
  • Yea, i also of input[type=file] but that is obtained through the local client machine. Can you tie a file input to that of a dynamically created javascript File? Commented Aug 12, 2013 at 16:51

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.