Results 1 to 3 of 3

Thread: [RESOLVED] uploading images

  1. #1
    Join Date
    Oct 2011
    Hamilton, Ontario

    resolved [RESOLVED] uploading images

    having trouble figuring out why this won't work. the picture doesn't appear in the directory afterwards and instead of a file path string in the db, it just says null in the next row in the db

    PHP Code:
    //connect to database

    //get text and page name

    //insert primary info into database
    $db->query("INSERT INTO ENTRIES(DATE, TEXT, category) VALUES (CURDATE(),'".$content."','".$page."')");

    $allowedExts = array("gif""jpeg""jpg""png");
    $location explode("."$_FILES["entry_pic"]["name"]);
    $extension end($location);
        if (((
    $_FILES["entry_pic"]["type"] == "image/gif")
          || (
    $_FILES["entry_pic"]["type"] == "image/jpeg")
          || (
    $_FILES["entry_pic"]["type"] == "image/jpg")
          || (
    $_FILES["entry_pic"]["type"] == "image/png"))
          && (
    $_FILES["entry_pic"]["size"] < 120000)
            if (
    $_FILES["entry_pic"]["error"] > 0)
    "Return Code: " $_FILES["entry_pic"]["error"] . "<br>";
    move_uploaded_file($_FILES['entry_pic']['tmp_name'], $target); 
    $db->query("UPDATE entries SET entry_pic_path = 'entry_pics/".$_FILES['entry_pic']['name']."'
                WHERE text='"
    "Invalid file";

  2. #2
    Join Date
    Mar 2007
    Your HTML? often these issues are based in what you put in your form tag.

    You will also find a thread that is stickied with a script for uploading images.

    My initial thoughts on your problem is to check that your enctype tag in your form is set.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  3. #3
    Join Date
    Oct 2011
    Hamilton, Ontario
    Oh my heck... lol i feel stupid now... yea it was my lack of enctype='multipart/form-data'. thanks a ton for that... silly dumb mistakes... I've done this before so I don't know why i forgot that. thanks for the reminder.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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

Recent Articles