Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: file upload

  1. #1
    New Coder
    Join Date
    Feb 2007
    Posts
    92
    Thanks
    1
    Thanked 0 Times in 0 Posts

    file upload

    I am using this code to allow a user to upload a file.

    $target_path = "upload/";

    $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!";
    }



    What i want to do is change the name of the file they upload.How do i upload the file and then change it's name?

    Thanks

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    It's the second parameter of the move_uploaded_file() function which you are already using so just change the second parameter.

  • #3
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Quote Originally Posted by bunny1 View Post
    PHP Code:
    $target_path $target_path basename$_FILES['uploadedfile']['name']); 
    Change it here ^


  •  

    Posting Permissions

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