Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
376 views
in Technique[技术] by (71.8m points)

php - How to upload a BitmapData Object straight to my server?

I wish to upload from my Flash Application (AS3) to imageshacks XML API. I wish to know how I can do this.

"In Flash, we must POST the data using the UrlRequest and UrlLoader classes, however we run into a limitation of the Flash API. The data property of a UrlRequest can either be a UrlVariablesByteArray object. There is no easy way to send name value pairs along with the JPG byte array. This is a big problem, because most upload applications will require a filename and other headers to accompany the raw file data"

I was hoping if someone could help me overcome the above!

Thanks all

Update

I have tried making use of this tutorial here:http://www.mikestead.co.uk/2009/01/04/upload-multiple-files-with-a-single-request-in-flash/

The problem is it's not for unsaved images, but it get images from your local machine and then uploads it to the server where the images has had a name already!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This was of great help to me: http://kitchen.braitsch.io/upload-bitmapdata-snapshot-to-server-in-as3/

You need to modify the URLRequestWrapper to insert field names and file names where needed. Here's what I've done:

bytes = 'Content-Disposition: form-data; name="' + $fieldName + '"; filename="';

It does the most formatting of headers so the server could understand it as a file upload.

By the way, if you have a BitmapData you might need to encode it to JPEG or PNG first.

Regards, Artem


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...