SitePoint Sponsor |
|
User Tag List
Results 1 to 2 of 2
Thread: Displaying images from database
-
Aug 6, 2000, 15:31 #1
- Join Date
- Jul 2000
- Posts
- 88
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I created a file upload form to upload images into my databse. I am now having trouble displaying those images on my web pages....The only thing that is displayed is: /tmp/php17616aa instead of the image...
I also added the following input to my forms...and mysql is still storing my photo under the /tmp/php17616aa scheme...
//insert photo stuff here
if ("image/pjpeg" == $businesslogo_type
or "image/gif" == $businesslogo_type) {
// Handle the file...
} else {
echo("<P>Please submit a JPEG or GIF image file.\n");
}
// Pick a file extension
if ( "image/pjpeg" == $businesslogo_type )
$extension = ".jpg";
else
$extension = ".gif";
// The complete path/filename
$filename = "C:\\Uploads\\" . time() .
$REMOTE_HOST . $extension;
// Copy the file
if (copy($businesslogo, $filename)) {
echo("<P>File stored successfully as $filename.");
} else {
echo("<P>Could not save file as $filename!");
}
-
Aug 6, 2000, 18:58 #2
- Join Date
- Apr 2000
- Location
- Melbourne, Australia
- Posts
- 2,571
- Mentioned
- 2 Post(s)
- Tagged
- 0 Thread(s)
The code you provide above copies the uploaded image to the C:\Uploads directory and assigns it a unique name ($filename). It seems to me that you must be storing $businesslogo (the temporary filename of the uploaded file) instead of $filename (the filename the uploaded file gets copied to permanently) in your database.
Make sense?
------------------
-Kevin Yank.
http://www.SitePoint.com/
Helping Small Business Grow Online!
Bookmarks