SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict einSTein's Avatar
    Join Date
    Aug 2006
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    error uploading same file in 2 different directories

    error uploading same file in 2 different directories, this is my code, it just upload the photo to the first directory

    PHP Code:
    $target_path "../img/";
    $dt=date("YmdHis");
    $target_path $target_path $dt basename$_FILES['uploadedfile']['name']); 
    $target_path2"img/" $dt .  basename$_FILES['uploadedfile']['name']);
    move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path);
    move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path2); 

  2. #2
    SitePoint Addict joaquin_win's Avatar
    Join Date
    Jul 2005
    Location
    Venezuela
    Posts
    224
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    move uploaded file efectively moves the temp file, so the second call wont find a file there.

    use php's copy function

    Code:
    copy($target_path, $target_path2);

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if (is_uploaded_file($_FILES['uploadedfile']['tmp_name'])) {
        
    copy($_FILES['uploadedfile']['tmp_name'], $target_path);
        
    copy($_FILES['uploadedfile']['tmp_name'], $target_path2);
        
    unlink($_FILES['uploadedfile']['tmp_name']);


  4. #4
    SitePoint Addict einSTein's Avatar
    Join Date
    Aug 2006
    Posts
    276
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanx


Bookmarks

Posting Permissions

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