| PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >> |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread |
|
|
#1 (permalink) |
|
Undercover Genius
Super #1
Joined in May 2003
Lives in Tampa, FL
Hosted on Vanilla
3,056 posts
Gave thanks: 27
Thanked 38 times
|
can you do that? remember that form I did awhile ago? well I want to add a spot to have an image uploaded into a field in that table. then have it displayed when the db contents is viewed on the site.
How would I go about doing that if this is possible. Thanks. :-)
__________________
When one door of happiness closes, another opens; but often we look so long at the closed door that we do not see the one which has been opened for us. - Helen Keller |
|
|
|
|
#2 (permalink) |
|
Undercover Genius
Super #1
Joined in May 2003
Lives in Tampa, FL
Hosted on Vanilla
3,056 posts
Gave thanks: 27
Thanked 38 times
|
anyone? :dongget:
__________________
When one door of happiness closes, another opens; but often we look so long at the closed door that we do not see the one which has been opened for us. - Helen Keller |
|
|
|
|
#3 (permalink) |
|
Registered User
Seasoned Poster
Joined in May 2003
Lives in Ottawa, Ontario, Canada
80 posts
Gave thanks: 0
Thanked 0 times
|
as far as i know:
no, you cannot upload an image to the DB. however, that dont mean you cant display images after querying the DB. what you need to do is tell the DB the name of the image when it is uploaded, and store than in info in a table. then, the user queries the DB for that image. you have a php page where you have an IMG tag, but instead of an actual image, have that info filled in by the DB. its not really that different than letting people submit links to your DB to add dynamicly to your site :o |
|
|
|
|
#4 (permalink) |
|
Registered User
Comfy Contributor
Joined in May 2003
Lives in ISREAL
258 posts
Gave thanks: 0
Thanked 0 times
|
you can't add images or anything like that to a DB...
text only, but as Xtreme said you can define what picture you want and your page will call it and display it, try it, if you need help ask.. |
|
|
|
|
#5 (permalink) |
|
Registered User
Comfy Contributor
Joined in May 2003
Lives in Florida
118 posts
Gave thanks: 0
Thanked 0 times
|
Sure you can. If you're using PHP then it has a global variable that allow you to retrieve a files info: size, type, name, data, etc... Which you can then use to upload a file via binary data by converting the data of the file using the PHP functions urlencode() and urldecode(). Then in your database, you would have a field to store the converted files binary data that would be of type 'BLOB'. Using this method you can upload more then just pictures. If needed then use LONGBLOB.
Here is a site with an example on uploading files via binary data and how to download/retrieve the information from the database by using PHP to dynamically recreating the file using the header() function. Storing: http://www.potentialcreations.com/articles/binary1.php Retrieving: http://www.potentialcreations.com/articles/binary2.php The example on that site allows any file to be uploaded, but that can be restricted to say jpeg’s by doing: (Example is going off your form being: <input name="filename" type="file">) if ($_FILES["filename"]["type"] == “image/jpeg”) { # Continue on with script } else { # Terminate the script and display error message echo “File type not allowed.”; }
__________________
Profession: Programmer, Gamer, Web Developer Website: http://www.reanimated.net/ - Server: Quela |
|
|
|
|
#6 (permalink) | |
|
Undercover Genius
Super #1
Joined in May 2003
Lives in Tampa, FL
Hosted on Vanilla
3,056 posts
Gave thanks: 27
Thanked 38 times
|
Quote:
The images aren't that big, maybe 5k at most and it won't be for public uploads, just me. :-)
__________________
When one door of happiness closes, another opens; but often we look so long at the closed door that we do not see the one which has been opened for us. - Helen Keller |
|
|
|
|
|
#7 (permalink) |
|
Registered User
Comfy Contributor
Joined in May 2003
Lives in ISREAL
258 posts
Gave thanks: 0
Thanked 0 times
|
you don't insert the pics into the DB, right?
don't think its possible... the way it works is that you define a pic by saying where its stored etc' at least as far as I know.. Keleigh if you mange to store pics right inside your DB let me know, I'm intreged by this... how would you use a pic if you store it in a DB? I mean, if you use html; <img src WHAT SHOULD GO HERE? wierd... |
|
|
|
|
#8 (permalink) |
|
Surpass Fan
Excelling Contributor
Joined in May 2003
Lives in Las Vegas, Nevada
Hosted on Dime9
632 posts
Gave thanks: 0
Thanked 0 times
|
Did you even look at the 2 sites he posted webster?
Storing: http://www.potentialcreations.com/articles/binary1.php Retrieving: http://www.potentialcreations.com/articles/binary2.php
__________________
Disclamer: This is not a legal document. As with all information transfered via the internet, this message was subject to possible contamination and tampering I hold myself harmless as to its content as at appears at its intended destination. |
|
|
|
|
#9 (permalink) |
|
Registered User
Comfy Contributor
Joined in May 2003
Lives in Florida
118 posts
Gave thanks: 0
Thanked 0 times
|
Ok well I could go on to explain how to use it with an img tag but its complicated and I'm not in the mood atm. :blink: I tested how it should work but it didn't work... script could be primarly for non-images. Anyways, use this script instead. I just tested it and it works fine.
Table info: http://www.phpbuilder.com/columns/florian19991014.php3?page=1 Storing: http://www.phpbuilder.com/columns/florian19991014.php3?page=2 Retreiving: http://www.phpbuilder.com/columns/florian19991014.php3?page=3
__________________
Profession: Programmer, Gamer, Web Developer Website: http://www.reanimated.net/ - Server: Quela |
|
|