{ "id": "66100", "key": "TIMOB-4311", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11358", "description": "Mobile 1.8.0 M05", "name": "Sprint 2011-26", "archived": true, "released": true, "releaseDate": "2011-07-04" } ], "resolution": { "id": "2", "description": "The problem described is an issue which will never be fixed.", "name": "Won't Fix" }, "resolutiondate": "2011-06-28T21:04:10.000+0000", "created": "2011-06-03T10:27:13.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [], "versions": [ { "id": "11244", "name": "Release 1.7.0", "archived": true, "released": true, "releaseDate": "2011-06-13" } ], "issuelinks": [], "assignee": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "updated": "2017-03-16T22:02:04.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "When you set Content-Type, it gets into the xhr.onload, but the responseText is \"There was an error uploading the file, please try again!\" and the file does not upload. If you remove \"xhr.setRequestHeader(\"Content-Type\", \"image/jpeg\");\" then it works fine and uploads the picture.\r\n\r\nStep 1: put uploads.php somewhere that you can run it and make an 'uploads' folder in the same directory\r\nStep 2: change the url in app.js to point to uploads.php.\r\nStep 3: run the example app.js code.\r\nStep 4: click 'upload'\r\nStep 5: select a picture\r\nStep 6: wait for response from the server.\r\n\r\n{code:title=\"app.js\"}\r\nvar win = Ti.UI.createWindow({\r\n backgroundColor: 'white'\r\n});\r\n\r\nvar button = Ti.UI.createButton({\r\n\ttitle:'upload',\r\n\theight: 50,\r\n\twidth: 200\r\n});\r\nbutton.addEventListener('click', function(e){\r\n\tTitanium.Media.openPhotoGallery({\r\n\t\tsuccess:function(event){\r\n\t\t\tvar myImage = event.media;\r\n\t\t\t\r\n\t\t\tvar sendImageData = { \r\n\t\t\t\t\t \"uploadedfile\": myImage\r\n\t\t\t\t\t };\r\n\r\n\t\t var xhr = Titanium.Network.createHTTPClient();\r\n\t\t xhr.open(\"POST\",\"http://_________/uploads.php\");\r\n\t\t xhr.setRequestHeader(\"enctype\", \"multipart/form-data\");\r\n\t\t xhr.setRequestHeader(\"Content-Type\", \"image/jpeg\");\r\n\t\t xhr.onload = function(e){\r\n\t\t\t\tTi.UI.createAlertDialog({title:'Success', message: this.responseText\r\n\t\t\t}).show();};\r\n\t\t xhr.onerror = function(e){alert(e.error);};\r\n\t\t xhr.send(sendImageData);\r\n\t\t},\r\n\t\tcancel:function(){\r\n\r\n\t\t},\r\n\t\terror:function(error){\r\n\t\t},\r\n\t\tmediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO]\r\n\t});\r\n});\r\n\r\nwin.add(button);\r\nwin.open();\r\n{code}\r\n{code:title=\"uploads.php\"}\r\n\r\n{code}\r\n\r\nh3. Trace\r\nhttp://pastie.org/private/4ne5vkfv5lc78vtklchg\r\n\r\nh3. Tested On\r\nTiSDK 1.7.0.RC1\r\nAndroid Emulator 2.1\r\n\r\nh3. Associated Helpdesk Ticket\r\nhttp://appc.me/c/APP-152932", "attachment": [], "flagged": false, "summary": "Android: Can't set Content-Type request header", "creator": { "name": "jalter", "key": "jalter", "displayName": "Jon Alter", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "jalter", "key": "jalter", "displayName": "Jon Alter", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "TiSDK 1.7.0.RC1\r\nAndroid Emulator 2.1", "comment": { "comments": [ { "id": "413248", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as the issue will not fix.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-16T22:02:04.000+0000", "updated": "2017-03-16T22:02:04.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }