doujia7094
2011-03-23 15:41 阅读 54
已采纳

Flex - 从数据库中检索base64编码图像

I'm developing a flex application that displays a list of images along with some metadata. The images are less than 500kb. They are stored in the database as base64 encoded strings, retrieved using PHP, send over to flex as XML (which creates a fairly large XML output file)

Now my problem is that, while I can display upto 2-3 images easily, anything more than 3 or sometimes 2 images will cause the images to be corrupt. Sometimes the whole app fails. I am guessing this is due to the large size of the generated XML. I know I am doing something wrong here. I want to know what is the proper method for storing/retrieving a lot of images in a flex application.

Also, is it a better option to save images as files and storing the path to these files in database ?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    dongzhou8764 dongzhou8764 2011-03-23 19:09

    Why are you 'storing' the images in an xml? Why don't you just send over the url to the images in the xml and let flex retrieve the images?

    Also, your xml was probably corrupt because a base64 image has some weird characters which can screw up xml parsing unless you have it wrapped in CDATA.

    点赞 评论 复制链接分享
  • dqwh1219 dqwh1219 2011-03-23 15:46

    Instead of passing it via XML, and since you're already on a PHP setup, you could try using AMF-PHP - it'll pass data between your server and app as native objects. Super slick.

    http://amfphp.sourceforge.net/

    点赞 评论 复制链接分享

相关推荐