Problem with uploading an image and copy that image into 2 places

Discussion in 'PHP' started by goutam.dutta123, Jan 3, 2008.

  1. #1
    Hello experts,

    I have successfully uploaded an image in a folder and copy that image into 2 other different folders.But when i upload pansy.jpg
    into original folder ,there are coming pansy.jpg & 63c7a940dc09c290c771e6dab74b7a22_pansy.jpg into original folder and when i copy it into edit & active folders there are coming pansy.jpg & 63c7a940dc09c290c771e6dab74b7a22_pansy.jpg into edit folder & same with active folder.
    I want the actual image name so that i can edit and save it for my online image editing project.Please help me in it.
    Here is my code:
    <?php
    session_start();
    if ($_POST['upload'])
    {
    $p1=$_FILES["imageName"]["name"];
    $t1=$_FILES["imageName"]["tmp_name"];
    $_SESSION['type']= $_FILES["imageName"]["type"];

    if ($_FILES["imageName"]["error"] > 0)
    {
    echo "Invalid File ";
    }
    else
    {
    if (file_exists("original/" . $_FILES["imageName"]["name"]))
    {
    $option='failure';
    }
    else
    {
    move_uploaded_file($_FILES["imageName"]["tmp_name"],
    "original/" . $_FILES["imageName"]["name"]);

    $source = "original/$p1";
    $destination1 = "active/$p1";
    $destination2 = "edit/$p1";
    copy($source, $destination1);
    copy($source, $destination2);
    }
    }
    }
    ?>
    Thanks...
     
    goutam.dutta123, Jan 3, 2008 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    <?php
    session_start();
    if ($_POST['upload'])
    {
    $p1=$_FILES["imageName"]["name"];
    $t1=$_FILES["imageName"]["tmp_name"];
    $_SESSION['type']= $_FILES["imageName"]["type"];

    if ($_FILES["imageName"]["error"] > 0)
    {
    echo "Invalid File ";
    }
    else
    {
    if (file_exists("original/" . $_FILES["imageName"]["name"]))
    {
    $option='failure';
    }
    else
    {
    move_uploaded_file($_FILES["imageName"]
    "original/" . $_FILES["imageName"]["name"]);

    $source = "original/$p1";
    $destination1 = "active/$p1";
    $destination2 = "edit/$p1";
    copy($source, $destination1);
    copy($source, $destination2);
    }
    }
    }
    ?>
     
    kmap, Jan 3, 2008 IP