I try to upload an image via Twitter api , as described there I created a form with name="status"
and name="media[]"
-
<form id="image-form">
<input type="text" name="status">
<input name="media[]" type="file" />
<input type="submit" value="POST IMAGE">
</form>
in addition I have a submit
handler -
$('#image-form').submit( function(e) {
e.preventDefault();
var formData = new FormData(this); // <-- 'this' is your form element
$.ajax({
url:'https://api.twitter.com/1.1/statuses/update_with_media.json',
type: 'POST',
contentType: false,
pagerocessData: false,
processData: false,
data: formData,
success: function(data) {
alert('Image upload succeeded');
},
error: function (responseData, textStatus, errorThrown) {
alert('GET failed.');
}
});
});
Under Networks at Chrome I see this request with Content-Type:multipart/form-data
finally I get "response 200" but it doesn't upload an image to the Twitter account ,
What I did wrong here ?