Welcome, Guest. Please login or register.
Did you miss your activation email?
05/22/12, 06:56
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  Server side Scripting and Database Support
| |-+  MySQL, PostgreSQL, MS SQL, Access (Moderators: Flash-db, Musicman, Ronald Wernecke, Jorge Solis, Andries Seutens)
| | |-+  How do I upload a user image into my MySQL database?
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: How do I upload a user image into my MySQL database?  (Read 6670 times)
Jaylada
Seasoned Programmer
***
Posts: 144



View Profile WWW Email
« on: 05/23/09, 17:44 »

Once I have the path name of the users image, how do I allow them to upload it into my database?

Thanks in advance
J
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #1 on: 05/24/09, 02:02 »

First of all some things to be made clear:

You want a user to upload an image
Then this image should be stored in the database
What about the Path?

A common methode storing images, is using space on the filesystem of the server.
Then you just write the path and filename into the database.
When you want to retreive the image, you read the database record, to findout about the path, and then send the complete path (added with the server section) to the browser or flash clip to be loaded.

Sometimes, usualy for security reasons, people store the image in a blob-field inside of the database.
I think, this is not what you wanted?
You can handle an image like a binary block of string. This is then stored to the database.
Reading is a little more complicated, because the link to the browser is the script retreiving the image, having a image header and sending the image from the database.
Logged

happy flashing
Cool
Ronald
Jaylada
Seasoned Programmer
***
Posts: 144



View Profile WWW Email
« Reply #2 on: 05/25/09, 10:03 »

I've allowed the user to type in the path name, local on their computer to store.
I do need to have security in mind, so I will look into the Blob field.  Currently the only image types I plan to let them upload are .jpg or .png, hopefully that is compatable with a blob field....?  This is the binary block of string method you talk about?

The method where you say store the file on filesystem of the server, is there a secure method to do this?

Thank you for the help, this is very helpful knowing where to start.
J
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #3 on: 05/25/09, 13:05 »

usualy the upload section is separated and, if you do it with php, you can control, where the file will be stored.
The section, where images reside, is set to not executable.
You name the file as you like - for instance, make all images to be jpg, resize them, before you store them - etc.
For those operations you can use the GD library of php.
You can limit the size, a user can upload.
Even when you store the image in a blob field, first the server loads it into a temporary file.

For details read the php manual about the image manipulating methods and commands.
Logged

happy flashing
Cool
Ronald
Elwood4Pena
Server what's that
*
Posts: 1


View Profile Email
« Reply #4 on: 10/14/10, 02:38 »

You instead save the image to your server, but keep a record in the database of what file was saved so you can easily reference the image when needed.
This will be more convenient.
Logged

Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
anything