Skip to main content
Inspiring
June 11, 2012
Answered

Using flash to post an image into a mysql database

  • June 11, 2012
  • 2 replies
  • 3907 views

How can I use flash to insert an image into a mysql database?

I have an android app I'm making where someone post a picture and the picture appears in a mysql database.

This is how I'm doing it: I'm making a php page where in the link you put  like this: example.com/example.php?IMAGE= ______ and it puts it in the mysql database. Only what do I put in the ______ part that will make the picture appear in the mysql database? In flash I'm using getURL to go to the url listed above.

How do I make the picture that they take in my app appear in the ______ part of the link and into my mysql database?

This topic has been closed for replies.
Correct answer sinious

Okay. I understand that it isn't smart to upload your image to mysql, but I'd like to give it a try.

If you still don't want me to try, give me a list of the disadvantages.

And what are the advantages of binary and how can I use them?


Again, you can just hit edit rather than making 2 posts. People get emails every time you post. You just sprayed me with emails.

If you can upload with flash and your problem is server side related, try the appropriate forum as that has nothing to do with Flash. Perhaps the Dreamweaver forum.

Good luck

2 replies

esdebon
Inspiring
June 11, 2012

What kind of variable receives the PHP file?,

Usually what is done is to convert the image into a byte array and send


Gh-AfgAuthor
Inspiring
June 11, 2012

can you create a byte array in mysql and have it converted back into flash?

how would i make the array it the link?

sinious
Legend
June 11, 2012

You should search google for AJAX uploader scripts. Almost all use flash, are free and have source code. Just use prewritten code for that. They come with the PHP also and the code is simple.

It all uses URLLoader or Socket (rare/advanced) to send the data in binary (fast). Then you can save that binary directly to a blob in mysql (unrecommended) or to a file on the server.

Gh-AfgAuthor
Inspiring
June 11, 2012

can you give me a tutorial?

sinious
Legend
June 11, 2012

Is there any good reason you want to save such potentially enormous data in a database rather than the filesystem? You can just use mysql to pair the uploaded files with a specific user and keep it simple.

Here's you're run of the mill uploader with a demo included, all the source, etc.

http://code.google.com/p/swfupload/

If you do decide to save it in a database then you literally just have PHP read the binary data and pass it directly through (with a proper image header) and Flash can load it like a regular image. It's literally MySQL Binary -> PHP -> Flash and it just shows up as the file type you designate.