SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    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!");
    }

  2. #2
    SitePoint Author Kevin Yank's Avatar
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •