0

I have a Base64 image string, i need to set the value of an input type file field, i have no control of the server side, or of the site, so it has to be done like this.

Is this possible?

FB API request / response on img upload

enter image description here

The response is a very long jS string setting some values, its very very very long, cannot post due to char restriction on SO.

This seems to be how the image is addeded to a post:

<input type="file" class="_n _5f0v" title="Vælg en fil at overføre" multiple="1" name="composer_unpublished_photo[]" aria-label="Føj billeder til dit opslag" id="js_h">

This is what happens when a post is posted, containing an image, the post only seems to reference the image, that has been pre-uploaded, on the prev request i posted.

enter image description here

1 Answers1

0

need to set the value of an input type file field, i have no control of the server side, or of the site, so it has to be done like this.

Is this possible?

No, it is not possible to "set" the FileList object , or File object of an input element

An object of this type is returned by the files property of the HTML <input> element; this lets you access the list of files selected with the <input type="file"> element.

var file = document.getElementById('fileItem').files[0];

Method overview

File item(index);

Properties

Attribute Type Description

length integer A read-only value indicating the number of files in the list.

guest271314
  • 1
  • 15
  • 104
  • 177
  • So i have to mimic the API call, rather then just call the .submit() on the form –  Aug 23 '15 at 17:27
  • @IvanRistic _"I can include JS ofc"_ Yes , would perhaps be helpful for viewers of Question to reproduce `html` , `js` ? _"So i have to mimic the API call, rather then just call the .submit() on the form"_ Not certain interpret Question correctly ? What is expected result ? – guest271314 Aug 23 '15 at 17:34
  • I need to auto upload an image to a facebook post. Using a chrome ext. –  Aug 23 '15 at 18:37
  • Setting the text is easy, but uploading the image is quite hard since i cannot set the value of the input field and just mimic a .click(), i guess i have to send a request to FB, to get it uploaded with the post. –  Aug 23 '15 at 18:38
  • Try utilizing `$.post(url, {file:file})` . Not certain what format api expects file as ? Will api accept `Blob` ? , or `json` object ? See also http://stackoverflow.com/questions/28856729/upload-multiple-image-using-ajax-php-and-jquery/ – guest271314 Aug 23 '15 at 18:41
  • It seems like facebook uploads the image as a form multitype, and returns some javascript. This seems quite complicated with param names that do not make sense, wish i could hire someone for this. Any suggestions on where to find facebook unofficial API experts :- P Images have been added to the edit from charles proxy. –  Aug 23 '15 at 22:54