Uploading files... having problems.

Discussion in 'PHP' started by wvccboy, Feb 11, 2008.

  1. #1
    Ok so I have my html form that uploads something.

    Here's my PHP code:

    $target_path = "uploads/";
    
    $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 
    
    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
        echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
        " has been uploaded";
    } else{
        echo "There was an error uploading the file, please try again!";
    }
    Code (markup):
    Couple things. Could I set this variable:

    $filename = " . basename( $_FILES['uploadedfile']['name']) ."

    to display my file name?

    Also, every time I upload it gives me the error uploading the file. I've set the directory to 777, and all but I'm kinda clueless as to why I'm not able to upload files.

    Thanks
     
    wvccboy, Feb 11, 2008 IP
  2. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #2
    What is the error?

    Peace,
     
    Barti1987, Feb 11, 2008 IP
  3. wvccboy

    wvccboy Notable Member

    Messages:
    2,632
    Likes Received:
    81
    Best Answers:
    1
    Trophy Points:
    250
    #3
    The file is not uploading to the uploads/ directory at all.

    Thanks
     
    wvccboy, Feb 11, 2008 IP
  4. -NB-

    -NB- Peon

    Messages:
    153
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Make sure that your hosting allows file uploads in the php configurations.
     
    -NB-, Feb 11, 2008 IP