Problem with uploading same image into 2 different folder by one click

Discussion in 'PHP' started by goutam.dutta123, Dec 21, 2007.

  1. #1
    Hello experts,

    I want to upload same image into 2 different folder by one submit button.But i can not do it. Here is my code .Please help me.
    <?php
    if ($_POST['upload']) {
    $p1=$_FILES["imageName"]["name"];
    $t1=$_FILES["imageName"]["tmp_name"];

    $p2=$_FILES["imageName"]["name"];
    $t2=$_FILES["imageName"]["tmp_name"];



    if(move_uploaded_file($t1 , "original/" . $p1))
    {
    move_uploaded_file($t2,"active/" . $p2);
    }
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>

    <body>
    <form name="frm" method="post" action="<?php $_SERVER['PHP_SELF']?>" enctype="multipart/form-data">
    <input type="file" name="imageName" /><input type="submit" name="upload" value="upload" />
    </form>
    </body>
    </html>
    Thanks....
     
    goutam.dutta123, Dec 21, 2007 IP
  2. AsHinE

    AsHinE Well-Known Member

    Messages:
    240
    Likes Received:
    8
    Best Answers:
    1
    Trophy Points:
    138
    #2
    I suggest you use
    copy()
    PHP:
    function.
    You know path to uploadad file after move_uploaded_file() - then just copy it.
     
    AsHinE, Dec 21, 2007 IP
  3. ndreamer

    ndreamer Guest

    Messages:
    339
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    do something more along the lines of

    if(is_uploaded_file($uploadedfile)) {
    copy($uploadedfile,$dest1);
    rename($uploadedfile,$dest2)
    }
     
    ndreamer, Dec 21, 2007 IP
  4. goutam.dutta123

    goutam.dutta123 Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks a lot ..I have used the copy() function and it works fine..

    Thank again
     
    goutam.dutta123, Dec 21, 2007 IP