I’m trying to upload an image to imageshack using flex, but keep getting
<links>
<error id="wrong_file_type">Wrong file type detected for file IMG_00000009.jpg:application/octet-stream</error>
</links>
I’ve tried changing the mimetype, but nothing seems to quite do it.
Here’s what my method looks like:
protected function onUpload(event:MouseEvent):void
{
trace('uploading')
fileRef.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, completeHandler);
var params:URLVariables = new URLVariables();
params.key = key;
var request:URLRequest = new URLRequest("http://www.imageshack.us/upload_api.php");
request.method = URLRequestMethod.POST;
request.data = params;
fileRef.upload(request, "fileupload");
}
Could anyone give me a hand here and tell me what i;m doing wrong? I’ve looked all around google and here, but can’t find any kind of workaround for his in actionscript.
Thanks in advance
There are multiple content types for a multi-part form upload. One for the main submission and one for each of the parts. You can’t set any of them when using the FileReference.upload() method. Sadly, you may have to build your own multi-part form upload with the content types that imageshack wants. You can do this with the URLLoader class, but it isn’t pretty.
Here’s a class that should get you started (possibly you can use it without modification): http://code.google.com/p/in-spirit/source/browse/#svn%2Ftrunk%2Fprojects%2FMultipartURLLoader%2Fru%2Finspirit
You might also ask imageshack to accept application/octet-stream for images on behalf of flash developers everywhere.
You can also file a bug/enhancement request at http://bugbase.adobe.com (The feature is documented to work this way, so it’s more of an enhancement request).