1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Image upload problem

Discussion in 'PHP' started by bluearrow, Jan 12, 2008.

  1. #1
    I want to use this code to upload a image to a folder and I want image to be saved with the give name , not its original name.

    if the given name is " $imageName " where should i add this variable in this code ? :)


    $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";
    PHP:
    .
     
    bluearrow, Jan 12, 2008 IP
  2. WeBuster

    WeBuster Member

    Messages:
    27
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #2
    
    $_FILES['uploadedfile'][$imageName]
    
    PHP:
     
    WeBuster, Jan 12, 2008 IP
    bluearrow likes this.
  3. lfhost

    lfhost Peon

    Messages:
    232
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    
    $ImageName = "newname.jpg";
    $target_path = $target_path . $ImageName; 
    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
        echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
        " has been uploaded";
    }
    PHP:
     
    lfhost, Jan 12, 2008 IP
    bluearrow likes this.
  4. bluearrow

    bluearrow Well-Known Member

    Messages:
    1,339
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    130
    #4
    Thanks guys. Got it sorted out. rep added to both of you. :)

    .
     
    bluearrow, Jan 12, 2008 IP